- Notifications
You must be signed in to change notification settings - Fork 25.5k
ESQL: Disallow mixed quoted/unquoted patterns in FROM #127636
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
ESQL: Disallow mixed quoted/unquoted patterns in FROM #127636
Conversation
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.
LGTM.
The only thing I would add is that LOOKUP JOIN also uses the same approach at parsing index patterns. There are various tests in StatementParserTests
that cover LOOKUP JOIN, but the current PR doesn't seem to change any of them. I may be wrong though, but mentioning this aspect for completeness sake. Thanks.
Thanks for the review and the caution note. Note: I'll let mark this PR as ready for review and merge it once the breaking change proposal is looked at and approved. |
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Hi @alex-spies, I've created a changelog YAML for you. Note that since this PR is labelled |
The LOOKUP JOIN parser dials back into |
| indexString (CAST_OP selectorString)? | ||
: clusterString COLON unquotedIndexString | ||
| unquotedIndexString CAST_OP selectorString | ||
| indexString |
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.
Is indexString used anywhere else?
If no, i wonder if that is going to be a bit more readable to have:
indexPattern : (clusterString COLON)? unquotedIndexString (CAST_OP selectorString)? | quotedIndexString
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.
Shouldn't remote:index::data
be supported as well?
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.
- We do not support selector strings for remote indices yet. This functionality is not added to ES.
indexString
is definitely used. Consider:FROM "my_index_name"
. In this case, the index name is represented byindexString
and is aQUOTED_STRING
. Look at line 128.
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.
@idegtiarenko , your suggestion would be more compact and I considered this at first; but the current approach avoids remote:index::data
directly in the grammar - leaving less room for missing a validation, until selectors will be made available for remote indices.
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 @pawankartik-elastic , I think this turned out real nice.
I have one optional remark, but this already LGTM and can be merged as-is IMO.
// Generate a syntactically invalid (partial quoted) pattern. | ||
var fromPatterns = randomIdentifier() + ":" + quote(randomIndexPatterns(without(CROSS_CLUSTER))); |
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.
nit: for even more completeness, I'd also add the partially quoted case where the cluster name is quoted but the index pattern is unquoted. Same below, and also applies to the partial quoting in case of selectors.
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.
Alright, I'll merge this PR and then open a separate PR for the new cases. I'm afraid if we lit it sit idle, there'd be too many conflicts to resolve.
I'll merge this PR once the BC gives an explicit approval. I've verified that the ANTLR auto-generated Java classes are up-to-date by re-running |
💔 Backport failed
You can use sqren/backport to manually backport by running |
@alex-spies according to this PR's labels, I need to update the changelog YAML, but I can't because the PR is closed. Please either update the changelog yourself on the appropriate branch, or adjust the labels. Specifically:
|
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Disallow partial quoting: individual quoting of constituent strings in an index pattern --------- Co-authored-by: Pawan Kartik <pawankartik.chitrapu@elastic.co> (cherry picked from commit 9021040) # Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/IdentifierGenerator.java
#129576) * ESQL: Disallow mixed quoted/unquoted patterns in FROM (#127636) Disallow partial quoting: individual quoting of constituent strings in an index pattern --------- Co-authored-by: Pawan Kartik <pawankartik.chitrapu@elastic.co> (cherry picked from commit 9021040) --------- Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
closes #1975 related PR: elastic/elasticsearch#127636
Closes #122651
Disallow quoting of parts of index patterns in ESQL that refer to a remote (CCS) index or have a failure store selector; all of the following will not work anymore:
(Also applies when wildcards
*
are used in the remote or index name.)If quotes are required, they can still be used but have to contain the whole index pattern, including the remote cluster and failure store selector; the following are the allowed versions of the
FROM
commands above:Multiple index patterns can either be in quotes or not, consistent with ESQL's behavior for non-CCS and non-failure-store
FROM
commands; all of the following are equivalent (assuming we don't actually need quotes around any of the patterns):