-
Notifications
You must be signed in to change notification settings - Fork 25.4k
ESQL: Remove duplicated nested commands #123085
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) |
Hi @costin, I've created a changelog YAML for you. |
Fork grammar duplicated nested command declaration causing additional lexing to occur resulting in invalid field name declaration Relates to elastic#121948
3fc4d36
to
c5e5c67
Compare
NESTED_SORT : {this.isDevVersion()}? SORT -> type(SORT); | ||
NESTED_LIMIT : {this.isDevVersion()}? LIMIT -> type(LIMIT); |
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.
These cause parsing error since commands don't need to be nested. WHERE is declared here for the STATS avg() WHERE declaration -WHERE inside a command.
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.
Got it. Thank you.
@@ -678,8 +677,8 @@ INSIST_MULTILINE_COMMENT : MULTILINE_COMMENT -> channel(HIDDEN); | |||
// | |||
mode FORK_MODE; | |||
FORK_LP : LP -> type(LP), pushMode(DEFAULT_MODE); | |||
FORK_RP : RP -> type(RP), popMode; |
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.
The popup mode should already be completed by the sub fork, otherwise the mode stack is not completed, causing non-first subqueries to fail (since parsing is executed in a different mode).
Hi @costin, I've created a changelog YAML for you. |
@@ -3085,7 +3085,28 @@ public void testInvalidFork() { | |||
"line 1:20: mismatched input 'FORK' expecting {'limit', 'sort', 'where'}" | |||
); | |||
expectError("FROM foo* | FORK ( x+1 ) ( WHERE y>2 )", "line 1:20: mismatched input 'x+1' expecting {'limit', 'sort', 'where'}"); | |||
expectError("FROM foo* | FORK ( LIMIT 10 ) ( y+2 )", "line 1:33: mismatched input 'y' expecting {'limit', 'sort', 'where'}"); | |||
expectError("FROM foo* | FORK ( LIMIT 10 ) ( y+2 )", "line 1:33: mismatched input 'y+2' expecting {'limit', 'sort', 'where'}"); |
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.
Good catch. I dunno why this escaped the CI testing in the PR that added the test scenario! ? (I'll check this separately)
pr: 123085 | ||
summary: Remove duplicated nested commands | ||
area: ES|QL | ||
type: bug |
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.
definitely a bug, but it should not escape into a published artifact or release.
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.
Thank you for fixing. And apologies for breaking in the first place. LGTM
I updated the branch with main in order to pickup #122586 ( which I see causing failures in this PR ) |
Due to recent grammar changes made ( token to no longer be reported by its text rather by his internal token name. Due to the use of pushMode, the symbol is not treated as a literal rather as a symbol. To address this, the parser listener looks at the error message and changes the message before returning it to the user. Replace hacky regex approach with Vocabulary substitution (not as pluggable as it could be yet much better) Fix #124145 Relates #123085 #121948 Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
Due to recent grammar changes made ( token to no longer be reported by its text rather by his internal token name. Due to the use of pushMode, the symbol is not treated as a literal rather as a symbol. To address this, the parser listener looks at the error message and changes the message before returning it to the user. Replace hacky regex approach with Vocabulary substitution (not as pluggable as it could be yet much better) Fix elastic#124145 Relates elastic#123085 elastic#121948 Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
Due to recent grammar changes made ( token to no longer be reported by its text rather by his internal token name. Due to the use of pushMode, the symbol is not treated as a literal rather as a symbol. To address this, the parser listener looks at the error message and changes the message before returning it to the user. Fix elastic#124145 Relates elastic#123085 elastic#121948
Due to recent grammar changes made ( token to no longer be reported by its text rather by his internal token name. Due to the use of pushMode, the symbol is not treated as a literal rather as a symbol. To address this, the parser listener looks at the error message and changes the message before returning it to the user. Fix #124145 Relates #123085 #121948
Rework fork nested declaration to properly pop the mode stack otherwise, parsing gets stuck inside expression mode
and removed duplicated commands that caused lexing errors.
Without this fix, queries that previously were working such as:
FROM index | STATS avg(max.limit)
failed.Relates to #121948