forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
4,285 additions
and
4,272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
parser grammar Expression; | ||
|
||
booleanExpression | ||
: NOT booleanExpression #logicalNot | ||
| valueExpression #booleanDefault | ||
| regexBooleanExpression #regexExpression | ||
| left=booleanExpression operator=AND right=booleanExpression #logicalBinary | ||
| left=booleanExpression operator=OR right=booleanExpression #logicalBinary | ||
| valueExpression (NOT)? IN LP valueExpression (COMMA valueExpression)* RP #logicalIn | ||
| valueExpression IS NOT? NULL #isNull | ||
| matchBooleanExpression #matchExpression | ||
; | ||
|
||
regexBooleanExpression | ||
: valueExpression (NOT)? kind=LIKE pattern=string | ||
| valueExpression (NOT)? kind=RLIKE pattern=string | ||
; | ||
|
||
matchBooleanExpression | ||
: fieldExp=qualifiedName (CAST_OP fieldType=dataType)? COLON matchQuery=constant | ||
; | ||
|
||
valueExpression | ||
: operatorExpression #valueExpressionDefault | ||
| left=operatorExpression comparisonOperator right=operatorExpression #comparison | ||
; | ||
|
||
operatorExpression | ||
: primaryExpression #operatorExpressionDefault | ||
| operator=(MINUS | PLUS) operatorExpression #arithmeticUnary | ||
| left=operatorExpression operator=(ASTERISK | SLASH | PERCENT) right=operatorExpression #arithmeticBinary | ||
| left=operatorExpression operator=(PLUS | MINUS) right=operatorExpression #arithmeticBinary | ||
; | ||
|
||
primaryExpression | ||
: constant #constantDefault | ||
| qualifiedName #dereference | ||
| functionExpression #function | ||
| LP booleanExpression RP #parenthesizedExpression | ||
| primaryExpression CAST_OP dataType #inlineCast | ||
; | ||
|
||
functionExpression | ||
: functionName LP (ASTERISK | (booleanExpression (COMMA booleanExpression)* (COMMA mapExpression)?))? RP | ||
; | ||
|
||
functionName | ||
: identifierOrParameter | ||
; | ||
|
||
mapExpression | ||
: LEFT_BRACES entryExpression (COMMA entryExpression)* RIGHT_BRACES | ||
; | ||
|
||
entryExpression | ||
: key=string COLON value=constant | ||
; | ||
|
||
constant | ||
: NULL #nullLiteral | ||
| integerValue UNQUOTED_IDENTIFIER #qualifiedIntegerLiteral | ||
| decimalValue #decimalLiteral | ||
| integerValue #integerLiteral | ||
| booleanValue #booleanLiteral | ||
| parameter #inputParameter | ||
| string #stringLiteral | ||
| OPENING_BRACKET numericValue (COMMA numericValue)* CLOSING_BRACKET #numericArrayLiteral | ||
| OPENING_BRACKET booleanValue (COMMA booleanValue)* CLOSING_BRACKET #booleanArrayLiteral | ||
| OPENING_BRACKET string (COMMA string)* CLOSING_BRACKET #stringArrayLiteral | ||
; | ||
|
||
booleanValue | ||
: TRUE | FALSE | ||
; | ||
|
||
numericValue | ||
: decimalValue | ||
| integerValue | ||
; | ||
|
||
decimalValue | ||
: (PLUS | MINUS)? DECIMAL_LITERAL | ||
; | ||
|
||
integerValue | ||
: (PLUS | MINUS)? INTEGER_LITERAL | ||
; | ||
|
||
string | ||
: QUOTED_STRING | ||
; | ||
|
||
comparisonOperator | ||
: EQ | NEQ | LT | LTE | GT | GTE | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
parser grammar Join; | ||
|
||
joinCommand | ||
: type=(JOIN_LOOKUP | DEV_JOIN_LEFT | DEV_JOIN_RIGHT) JOIN joinTarget joinCondition | ||
; | ||
|
||
joinTarget | ||
: index=indexPattern | ||
; | ||
|
||
joinCondition | ||
: ON joinPredicate (COMMA joinPredicate)* | ||
; | ||
|
||
joinPredicate | ||
: valueExpression | ||
; | ||
|
||
|
38 changes: 19 additions & 19 deletions
38
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.