Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl.get_schema must return field name in index parts #53

Open
akudiyar opened this issue Feb 15, 2021 · 4 comments
Open

ddl.get_schema must return field name in index parts #53

akudiyar opened this issue Feb 15, 2021 · 4 comments
Labels
feature A new functionality teamE

Comments

@akudiyar
Copy link
Contributor

Currently there is no way to easily determine the field number or the field name from the returned "path" field: either a sophisticated logic is needed (splitting the value by dot, etc) or it is completely impossible for multikey indexes.

This is needed for connectors (e.g. cartridge-java).

@akudiyar akudiyar added the feature A new functionality label Feb 15, 2021
@rosik
Copy link
Contributor

rosik commented Feb 15, 2021

But index part ~= field. Sometimes they may coincide, but in general, they don't. That's how tarantool works.

@Totktonada
Copy link
Member

It would be easier to discuss it with examples and user scenarious.

Let's assume we have a space with the following format:

{
    {name = 'id', type = 'string', is_nullable = false},
    {name = 'full_name', type = 'string', is_nullable = true},
    {name = 'email', type = 'string', is_nullable = true},
}

And the following secondary index:

{
    type = 'TREE',
    name = 'middle_name',
    unique = false,
    parts = {
        {path = 'full_name.middle_name', type = 'string', is_nullable = true, collation = nil},
    },
}

The index 'middle_name' uses a piece of 'full_name' field information. What kind of task requires information from which field this piece of information is originated? Feel free to show it on another example. I want to understand a user scenario here.

@Totktonada Totktonada added the needs feedback Something is unclear with the issue label Oct 14, 2021
@kyukhin kyukhin modified the milestone: wishlist Feb 11, 2022
@akudiyar
Copy link
Contributor Author

akudiyar commented Mar 17, 2022

Matching between index fields and field positions is necessary for making correct box API requests with index values from an entity through a connector.

Let's consider the entity in your example. When you are writing an index query, you'll use something like

box.space.user.index.secondary:select(my_user.full_name.middle_name
) -- "Ivanovich"

But when we are using connectors, often we have an entity backed by a tuple and we need to guess which field of it we need to pick for putting as the value for this query. And furthermore, if we are trying to determine the best index for querying something according to the user's request, we need to match several indexes and pick up the narrower one. There we start calculating the longest index value tuple -- you can see an example in cartridge-java (look at the Conditions.java class). And for making these index value tuples we need to match a position in an index to a tuple field.

@Totktonada Totktonada removed the needs feedback Something is unclear with the issue label Mar 17, 2022
@kyukhin kyukhin added the teamE label Apr 8, 2022
@Totktonada
Copy link
Member

We discussed it with Alexey voicely. I'd like to summarize how I understood the problem.

Context: a client side ORM needs full schema data to implement pagination. A pagination requires key extraction from a tuple, including key parts that corresponds to an index key part defined by a JSON path.

The problem is that it is unclear, how exactly interpret JSON path key part definition. The solution would be a clear description of the algorithm and, if needed, changes in tarantool or tarantool/ddl to define it.

What is not clear:

  1. JSON path index allows to set a path starting from root of a tuple (including a field name) or starting from a field (excluding a field name). Whether tarantool normalizes both forms into one? Whether tarantool/ddl does?
  2. Whether field name is always defined or missed if the path field contains it (on tarantool level and on tarantool/ddl level)?

@Totktonada Totktonada removed their assignment Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality teamE
Projects
None yet
Development

No branches or pull requests

6 participants