Skip to content

Commit 21845ad

Browse files
authored
ESQL: Remove duplicated nested commands (#123085)
Fork grammar duplicated nested command declaration causing additional lexing to occur resulting in invalid field name declaration Relates to #121948
1 parent afd7e4e commit 21845ad

File tree

9 files changed

+1282
-1292
lines changed

9 files changed

+1282
-1292
lines changed

docs/changelog/123085.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123085
2+
summary: Remove duplicated nested commands
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,12 @@ IN: 'in';
195195
IS: 'is';
196196
LAST : 'last';
197197
LIKE: 'like';
198-
LP : '(';
199198
NOT : 'not';
200199
NULL : 'null';
201200
NULLS : 'nulls';
202201
OR : 'or';
203202
PARAM: '?';
204203
RLIKE: 'rlike';
205-
RP : ')';
206204
TRUE : 'true';
207205

208206
EQ : '==';
@@ -223,8 +221,6 @@ LEFT_BRACES : '{';
223221
RIGHT_BRACES : '}';
224222

225223
NESTED_WHERE : WHERE -> type(WHERE);
226-
NESTED_SORT : {this.isDevVersion()}? SORT -> type(SORT);
227-
NESTED_LIMIT : {this.isDevVersion()}? LIMIT -> type(LIMIT);
228224

229225
NAMED_OR_POSITIONAL_PARAM
230226
: PARAM (LETTER | UNDERSCORE) UNQUOTED_ID_BODY*
@@ -239,6 +235,9 @@ NAMED_OR_POSITIONAL_PARAM
239235
OPENING_BRACKET : '[' -> pushMode(EXPRESSION_MODE), pushMode(EXPRESSION_MODE);
240236
CLOSING_BRACKET : ']' -> popMode, popMode;
241237

238+
LP : '(' -> pushMode(EXPRESSION_MODE), pushMode(EXPRESSION_MODE);
239+
RP : ')' -> popMode, popMode;
240+
242241
UNQUOTED_IDENTIFIER
243242
: LETTER UNQUOTED_ID_BODY*
244243
// only allow @ at beginning of identifier to keep the option to allow @ as infix operator in the future
@@ -678,8 +677,8 @@ INSIST_MULTILINE_COMMENT : MULTILINE_COMMENT -> channel(HIDDEN);
678677
//
679678
mode FORK_MODE;
680679
FORK_LP : LP -> type(LP), pushMode(DEFAULT_MODE);
681-
FORK_RP : RP -> type(RP), popMode;
682680
FORK_PIPE : PIPE -> type(PIPE), popMode;
681+
683682
FORK_WS : WS -> channel(HIDDEN);
684683
FORK_LINE_COMMENT : LINE_COMMENT -> channel(HIDDEN);
685684
FORK_MULTILINE_COMMENT : MULTILINE_COMMENT -> channel(HIDDEN);

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Lines changed: 49 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.tokens

Lines changed: 49 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.interp

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)