-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Support index pattern selector syntax in SQL #120845
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
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Pinging @elastic/es-data-management (Team:Data Management) |
*/ | ||
@Override | ||
public void visitErrorNode(ErrorNode node) {} | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire file was regenerated with inconsistent formatting. Is this something that should be checked in as part of this PR? Does this get regenerated as needed during the build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generated by ANTLR, I typically run a spotlessApply
to fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jbaiera, I had a look and left a first round of comments.
I think this needs more strict validation at parse time, to make sure that we only accept valid selectors.
I also tried to run queries with normal indices (non-datastreams), and the behavior is not what I expected:
- with
select * from person::data
everything works fine - with
select * from person::failures
I still get the data. I expectedno such index [person::failures]
as in _search, or at least no data - with
select * from person::foo
I still get the data. I expected a validation exception like in _search:Invalid index name [person::foo], invalid usage of :: separator, [foo] is not a recognized selector
x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/parser/SqlParserTests.java
Show resolved
Hide resolved
...ugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/UnresolvedRelationTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/parser/SqlParserTests.java
Show resolved
Hide resolved
@luigidellaquila I combed through the code and found that some portions of the code used the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating on this @jbaiera, LGTM
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Updates the SQL grammar to include the selector portion of an index pattern. The index() method has been updated to include selectors in the resulting expression. (cherry picked from commit 299bf44)
Updates the SQL grammar to include the selector portion of an index pattern. The index() method has been updated to include selectors in the resulting expression.
Updates the SQL grammar to include the selector portion of an index pattern. The index() method has been updated to include selectors in the resulting expression. (cherry picked from commit 299bf44) Co-authored-by: Elastic Machine <[email protected]>
Selector syntax (#118614) was introduced as part of the work to support implementing failure stores in data streams. This is a new feature of index patterns which allows a user to specify which indices inside of a data stream should be used in an action. Selectors are denoted by using the :: separator between a data stream name and the component of the data stream the user wants to target for an operation.
To search a data stream's backing indices, the ::data selector is used:
To search a data stream's failure indices, the ::failures selector is used:
By default, when a data stream has no selector specified, the ::data selector is implied to maintain backwards compatibility with current search functionality. The ::data selector primarily exists as a way to explicitly select the backing indices, but is not required for normal usage.
This PR updates the SQL grammar to include the selector portion of an index pattern. The
qualifiedIndex()
has been updated to include selectors in the resulting expression. Underlying search operations should already support this functionality, so this is primarily wiring it up where needed.