Skip to content

Commit

Permalink
[8.x] [ES|QL] Update grammars (#196992) (#197076)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Update grammars
(#196992)](#196992)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kibana
Machine","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T14:25:39Z","message":"[ES|QL]
Update grammars (#196992)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\r\nlatest version in
Elasticsearch.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli
<[email protected]>","sha":"78f1a8806b4dc07195e6182f220130f513b3cca2","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Feature:ES|QL","Team:ESQL","v8.16.0","backport:version","v8.17.0"],"title":"[ES|QL]
Update
grammars","number":196992,"url":"https://github.com/elastic/kibana/pull/196992","mergeCommit":{"message":"[ES|QL]
Update grammars (#196992)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\r\nlatest version in
Elasticsearch.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli
<[email protected]>","sha":"78f1a8806b4dc07195e6182f220130f513b3cca2"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196992","number":196992,"mergeCommit":{"message":"[ES|QL]
Update grammars (#196992)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\r\nlatest version in
Elasticsearch.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli
<[email protected]>","sha":"78f1a8806b4dc07195e6182f220130f513b3cca2"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
kibanamachine authored Oct 21, 2024
1 parent e1c4ca2 commit e4730d0
Show file tree
Hide file tree
Showing 18 changed files with 1,937 additions and 1,586 deletions.
21 changes: 10 additions & 11 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ WHERE : 'where' -> pushMode(EXPRESSION_MODE);
// MYCOMMAND : 'mycommand' -> ...
DEV_INLINESTATS : {this.isDevVersion()}? 'inlinestats' -> pushMode(EXPRESSION_MODE);
DEV_LOOKUP : {this.isDevVersion()}? 'lookup' -> pushMode(LOOKUP_MODE);
DEV_MATCH : {this.isDevVersion()}? 'match' -> pushMode(EXPRESSION_MODE);
DEV_METRICS : {this.isDevVersion()}? 'metrics' -> pushMode(METRICS_MODE);

//
Expand Down Expand Up @@ -211,8 +210,8 @@ ASTERISK : '*';
SLASH : '/';
PERCENT : '%';

// move it in the main section if the feature gets promoted
DEV_MATCH_OP : {this.isDevVersion()}? DEV_MATCH -> type(DEV_MATCH);
MATCH : 'match';
NESTED_WHERE : WHERE -> type(WHERE);

NAMED_OR_POSITIONAL_PARAM
: PARAM (LETTER | UNDERSCORE) UNQUOTED_ID_BODY*
Expand Down Expand Up @@ -308,8 +307,8 @@ mode PROJECT_MODE;
PROJECT_PIPE : PIPE -> type(PIPE), popMode;
PROJECT_DOT: DOT -> type(DOT);
PROJECT_COMMA : COMMA -> type(COMMA);
PROJECT_PARAM : PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
PROJECT_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
fragment UNQUOTED_ID_BODY_WITH_PATTERN
: (LETTER | DIGIT | UNDERSCORE | ASTERISK)
Expand Down Expand Up @@ -343,8 +342,8 @@ RENAME_PIPE : PIPE -> type(PIPE), popMode;
RENAME_ASSIGN : ASSIGN -> type(ASSIGN);
RENAME_COMMA : COMMA -> type(COMMA);
RENAME_DOT: DOT -> type(DOT);
RENAME_PARAM : PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
RENAME_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
AS : 'as';
Expand Down Expand Up @@ -416,8 +415,8 @@ ENRICH_FIELD_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
;

ENRICH_FIELD_PARAM : PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
ENRICH_FIELD_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

ENRICH_FIELD_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
Expand All @@ -434,8 +433,8 @@ ENRICH_FIELD_WS
mode MVEXPAND_MODE;
MVEXPAND_PIPE : PIPE -> type(PIPE), popMode;
MVEXPAND_DOT: DOT -> type(DOT);
MVEXPAND_PARAM : PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
MVEXPAND_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

MVEXPAND_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
Expand Down
10 changes: 5 additions & 5 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.interp

Large diffs are not rendered by default.

163 changes: 82 additions & 81 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@ STATS=15
WHERE=16
DEV_INLINESTATS=17
DEV_LOOKUP=18
DEV_MATCH=19
DEV_METRICS=20
UNKNOWN_CMD=21
LINE_COMMENT=22
MULTILINE_COMMENT=23
WS=24
PIPE=25
QUOTED_STRING=26
INTEGER_LITERAL=27
DECIMAL_LITERAL=28
BY=29
AND=30
ASC=31
ASSIGN=32
CAST_OP=33
COMMA=34
DESC=35
DOT=36
FALSE=37
FIRST=38
IN=39
IS=40
LAST=41
LIKE=42
LP=43
NOT=44
NULL=45
NULLS=46
OR=47
PARAM=48
RLIKE=49
RP=50
TRUE=51
EQ=52
CIEQ=53
NEQ=54
LT=55
LTE=56
GT=57
GTE=58
PLUS=59
MINUS=60
ASTERISK=61
SLASH=62
PERCENT=63
DEV_METRICS=19
UNKNOWN_CMD=20
LINE_COMMENT=21
MULTILINE_COMMENT=22
WS=23
PIPE=24
QUOTED_STRING=25
INTEGER_LITERAL=26
DECIMAL_LITERAL=27
BY=28
AND=29
ASC=30
ASSIGN=31
CAST_OP=32
COMMA=33
DESC=34
DOT=35
FALSE=36
FIRST=37
IN=38
IS=39
LAST=40
LIKE=41
LP=42
NOT=43
NULL=44
NULLS=45
OR=46
PARAM=47
RLIKE=48
RP=49
TRUE=50
EQ=51
CIEQ=52
NEQ=53
LT=54
LTE=55
GT=56
GTE=57
PLUS=58
MINUS=59
ASTERISK=60
SLASH=61
PERCENT=62
MATCH=63
NAMED_OR_POSITIONAL_PARAM=64
OPENING_BRACKET=65
CLOSING_BRACKET=66
Expand Down Expand Up @@ -134,42 +134,43 @@ CLOSING_METRICS_WS=120
'sort'=14
'stats'=15
'where'=16
'|'=25
'by'=29
'and'=30
'asc'=31
'='=32
'::'=33
','=34
'desc'=35
'.'=36
'false'=37
'first'=38
'in'=39
'is'=40
'last'=41
'like'=42
'('=43
'not'=44
'null'=45
'nulls'=46
'or'=47
'?'=48
'rlike'=49
')'=50
'true'=51
'=='=52
'=~'=53
'!='=54
'<'=55
'<='=56
'>'=57
'>='=58
'+'=59
'-'=60
'*'=61
'/'=62
'%'=63
'|'=24
'by'=28
'and'=29
'asc'=30
'='=31
'::'=32
','=33
'desc'=34
'.'=35
'false'=36
'first'=37
'in'=38
'is'=39
'last'=40
'like'=41
'('=42
'not'=43
'null'=44
'nulls'=45
'or'=46
'?'=47
'rlike'=48
')'=49
'true'=50
'=='=51
'=~'=52
'!='=53
'<'=54
'<='=55
'>'=56
'>='=57
'+'=58
'-'=59
'*'=60
'/'=61
'%'=62
'match'=63
']'=66
'metadata'=75
'as'=84
Expand Down
Loading

0 comments on commit e4730d0

Please sign in to comment.