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

IGNITE-16446: Fix IndexQuery incorrect work with indexes built for _VAL field #9788

Merged

Conversation

timoninmaxim
Copy link
Member

@timoninmaxim timoninmaxim commented Feb 2, 2022

IndexQuery handles indexes built for single _VAL (or alias) field correctly. Now it checks field type before sorting on an originating node.


/** */
private boolean isKeyField(String fld) {
return fld.equals(typeDesc.keyFieldAlias()) || fld.equals(QueryUtils.KEY_FIELD_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equalsIgnoreCase?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fld, keyFieldAlias are already normalized here, so it is impossible to fail with getting non-normalized keys here.

But, also we should keep in mind the CacheConfiguration#sqlEscapeAll() flag. In case it set up, a user have to specify field in the same way as it was declared. For example, if field declared as "f1", then with sqlEscapeAll=false it will be normalized to "F1" and user can query it with both "f1" or "F1". But if sqlEscapeAll=true, then field will be "f1" and user has to run query with "f1" attribute only, and it's prohibited to use "F1" for querying.

So String#equals works in both cases with or without escaping. I added tests for that.


/** */
private boolean isValueField(String fld) {
return fld.equals(typeDesc.valueFieldAlias()) || fld.equals(QueryUtils.VAL_FIELD_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equalsIgnoreCase?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same.


/** */
@Test
public void testKeyField() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add tests with upper/lower case letters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for cases and escaping.

Comment on lines 52 to 57
/** */
@Parameterized.Parameters(name = "escape={0}")
public static Object[] params() {
return new Object[] { false, true };
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is not parametrized, looks like this is redundant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@timoninmaxim timoninmaxim merged commit d52b3f9 into apache:master Feb 4, 2022
@timoninmaxim timoninmaxim deleted the IGNITE-16446__idx_qry_val_field branch February 4, 2022 14:31
xintrian pushed a commit to xintrian/ignite that referenced this pull request May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants