ES|QL: FUSE syntax fix when using options before SCORE/GROUP/KEY BY #139261
+2,045
−2,164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's a bug right now with FUSE, where
WITHcannot be used before the other configurations (SCORE BY/GROUP BY/KEY BY):returns:
This should not happen, looking at the parser, WITH/KEY BY/SCORE BY/GROUP BY don't need to be provided in any particular order:
elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4
Lines 344 to 353 in 3508148
The bug most likely has to do with mixing ANTLR push modes.
After spending some considerable time trying to fix it, I figured we can just follow the same pattern as the other commands that support options (using
WITH), that just use EXPRESSION_MODE.So I removed the custom Fuse.g4 lexer, and just used the Expression lexer like the other commands do 🙃 .
This not just simplifies how we define the syntax for FUSE, but it also fixes the bug we have.