-
Notifications
You must be signed in to change notification settings - Fork 216
Support full expression in WHERE clauses #3849
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c1f1062
Support full expression in WHERE clauses
LantaoJin 9d92f8f
add unit tests
LantaoJin 93ac6e1
Merge remote-tracking branch 'upstream/main' into issues/3273
LantaoJin 4b2ef51
revert typo
LantaoJin 5173edd
Fix IT
LantaoJin 71001e0
Fix IT
LantaoJin 2b8d0bd
Merge remote-tracking branch 'upstream/main' into issues/3273
LantaoJin 8fe66a0
Address comment
LantaoJin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,8 +18,8 @@ pplStatement | |
| ; | ||
|
|
||
| dmlStatement | ||
| : queryStatement | ||
| | explainStatement | ||
| : explainStatement | ||
| | queryStatement | ||
| ; | ||
|
|
||
| queryStatement | ||
|
|
@@ -43,9 +43,9 @@ subSearch | |
|
|
||
| // commands | ||
| pplCommands | ||
| : searchCommand | ||
| | describeCommand | ||
| : describeCommand | ||
| | showDataSourcesCommand | ||
| | searchCommand | ||
| ; | ||
|
|
||
| commands | ||
|
|
@@ -106,9 +106,9 @@ commandName | |
| ; | ||
|
|
||
| searchCommand | ||
| : (SEARCH)? fromClause # searchFrom | ||
| | (SEARCH)? fromClause logicalExpression # searchFromFilter | ||
| | (SEARCH)? logicalExpression fromClause # searchFilterFrom | ||
| : (SEARCH)? fromClause # searchFrom | ||
| | (SEARCH)? fromClause logicalExpression (logicalExpression)* # searchFromFilter | ||
| | SEARCH logicalExpression fromClause # searchFilterFrom | ||
| ; | ||
|
|
||
| describeCommand | ||
|
|
@@ -373,7 +373,7 @@ sortbyClause | |
| ; | ||
|
|
||
| evalClause | ||
| : fieldExpression EQUAL expression | ||
| : fieldExpression EQUAL logicalExpression | ||
| ; | ||
|
|
||
| eventstatsAggTerm | ||
|
|
@@ -447,68 +447,52 @@ numericLiteral | |
| | floatLiteral | ||
| ; | ||
|
|
||
| // expressions | ||
| expression | ||
| : logicalExpression | ||
| | comparisonExpression | ||
| | valueExpression | ||
| ; | ||
|
|
||
| // predicates | ||
| logicalExpression | ||
| : LT_PRTHS logicalExpression RT_PRTHS # parentheticLogicalExpr | ||
| | NOT logicalExpression # logicalNot | ||
| | left = logicalExpression (AND)? right = logicalExpression # logicalAnd | ||
| : NOT logicalExpression # logicalNot | ||
| | left = logicalExpression AND right = logicalExpression # logicalAnd | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ✅ ❌ (SPL cannot work either) ✅ This limitation is because functionArgs could be ambiguous. For example: can be parsed to an incorrect syntax tree: The correct syntax tree is
|
||
| | left = logicalExpression XOR right = logicalExpression # logicalXor | ||
| | left = logicalExpression OR right = logicalExpression # logicalOr | ||
| | comparisonExpression # comparsion | ||
| | booleanExpression # booleanExpr | ||
| | relevanceExpression # relevanceExpr | ||
| | expression # logicalExpr | ||
| ; | ||
|
|
||
| comparisonExpression | ||
| : left = valueExpression comparisonOperator right = valueExpression # compareExpr | ||
| | valueExpression NOT? IN valueList # inExpr | ||
| | valueExpression NOT? BETWEEN valueExpression AND valueExpression # between | ||
| ; | ||
|
|
||
| valueExpressionList | ||
| : valueExpression | ||
| | LT_PRTHS valueExpression (COMMA valueExpression)* RT_PRTHS | ||
| expression | ||
| : valueExpression # valueExpr | ||
| | relevanceExpression # relevanceExpr | ||
| | left = expression comparisonOperator right = expression # compareExpr | ||
| | expression NOT? IN valueList # inExpr | ||
| | expression NOT? BETWEEN expression AND expression # between | ||
| ; | ||
|
|
||
| valueExpression | ||
| : left = valueExpression binaryOperator = (STAR | DIVIDE | MODULE) right = valueExpression # binaryArithmetic | ||
| | left = valueExpression binaryOperator = (PLUS | MINUS) right = valueExpression # binaryArithmetic | ||
| | primaryExpression # valueExpressionDefault | ||
| | positionFunction # positionFunctionCall | ||
| | caseFunction # caseExpr | ||
| | extractFunction # extractFunctionCall | ||
| | getFormatFunction # getFormatFunctionCall | ||
| | timestampFunction # timestampFunctionCall | ||
| | LT_PRTHS valueExpression RT_PRTHS # parentheticValueExpr | ||
| | LT_SQR_PRTHS subSearch RT_SQR_PRTHS # scalarSubqueryExpr | ||
| | lambda # lambdaExpr | ||
| ; | ||
|
|
||
| primaryExpression | ||
| : left = valueExpression binaryOperator = (STAR | DIVIDE | MODULE) right = valueExpression # binaryArithmetic | ||
| | left = valueExpression binaryOperator = (PLUS | MINUS) right = valueExpression # binaryArithmetic | ||
| | literalValue # literalValueExpr | ||
| | functionCall # functionCallExpr | ||
| | lambda # lambdaExpr | ||
| | LT_SQR_PRTHS subSearch RT_SQR_PRTHS # scalarSubqueryExpr | ||
| | valueExpression NOT? IN LT_SQR_PRTHS subSearch RT_SQR_PRTHS # inSubqueryExpr | ||
| | LT_PRTHS valueExpression (COMMA valueExpression)* RT_PRTHS NOT? IN LT_SQR_PRTHS subSearch RT_SQR_PRTHS # inSubqueryExpr | ||
| | EXISTS LT_SQR_PRTHS subSearch RT_SQR_PRTHS # existsSubqueryExpr | ||
| | fieldExpression # fieldExpr | ||
| | LT_PRTHS logicalExpression RT_PRTHS # nestedValueExpr | ||
| ; | ||
|
|
||
| functionCall | ||
| : evalFunctionCall | ||
| | dataTypeFunctionCall | ||
| | fieldExpression | ||
| | literalValue | ||
| | positionFunctionCall | ||
| | caseFunctionCall | ||
| | timestampFunctionCall | ||
| | extractFunctionCall | ||
| | getFormatFunctionCall | ||
| ; | ||
|
|
||
| positionFunction | ||
| positionFunctionCall | ||
| : positionFunctionName LT_PRTHS functionArg IN functionArg RT_PRTHS | ||
| ; | ||
|
|
||
| booleanExpression | ||
| : booleanFunctionCall # booleanFunctionCallExpr | ||
| | valueExpressionList NOT? IN LT_SQR_PRTHS subSearch RT_SQR_PRTHS # inSubqueryExpr | ||
| | EXISTS LT_SQR_PRTHS subSearch RT_SQR_PRTHS # existsSubqueryExpr | ||
| ; | ||
|
|
||
| caseFunction | ||
| caseFunctionCall | ||
| : CASE LT_PRTHS logicalExpression COMMA valueExpression (COMMA logicalExpression COMMA valueExpression)* (ELSE valueExpression)? RT_PRTHS | ||
| ; | ||
|
|
||
|
|
@@ -573,12 +557,7 @@ evalFunctionCall | |
|
|
||
| // cast function | ||
| dataTypeFunctionCall | ||
| : CAST LT_PRTHS expression AS convertedDataType RT_PRTHS | ||
| ; | ||
|
|
||
| // boolean functions | ||
| booleanFunctionCall | ||
| : conditionFunctionName LT_PRTHS functionArgs RT_PRTHS | ||
| : CAST LT_PRTHS logicalExpression AS convertedDataType RT_PRTHS | ||
| ; | ||
|
|
||
| convertedDataType | ||
|
|
@@ -621,12 +600,12 @@ functionArg | |
|
|
||
| functionArgExpression | ||
| : lambda | ||
| | expression | ||
| | logicalExpression | ||
| ; | ||
|
|
||
| lambda | ||
| : ident ARROW expression | ||
| | LT_PRTHS ident (COMMA ident)+ RT_PRTHS ARROW expression | ||
| : ident ARROW logicalExpression | ||
| | LT_PRTHS ident (COMMA ident)+ RT_PRTHS ARROW logicalExpression | ||
| ; | ||
|
|
||
| relevanceArg | ||
|
|
@@ -837,7 +816,7 @@ dateTimeFunctionName | |
| | YEARWEEK | ||
| ; | ||
|
|
||
| getFormatFunction | ||
| getFormatFunctionCall | ||
| : GET_FORMAT LT_PRTHS getFormatType COMMA functionArg RT_PRTHS | ||
| ; | ||
|
|
||
|
|
@@ -848,7 +827,7 @@ getFormatType | |
| | TIMESTAMP | ||
| ; | ||
|
|
||
| extractFunction | ||
| extractFunctionCall | ||
| : EXTRACT LT_PRTHS datetimePart FROM functionArg RT_PRTHS | ||
| ; | ||
|
|
||
|
|
@@ -883,7 +862,7 @@ datetimePart | |
| | complexDateTimePart | ||
| ; | ||
|
|
||
| timestampFunction | ||
| timestampFunctionCall | ||
| : timestampFunctionName LT_PRTHS simpleDateTimePart COMMA firstArg = functionArg COMMA secondArg = functionArg RT_PRTHS | ||
| ; | ||
|
|
||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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 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
SEARCHkeyword changed to required since the querydescribe source=tcould be ambiguous.describe source=tshould throw syntax error "describe source= <==== .."But it could be matched to
logicalExpression -> valueExpr -> fieldExpr ->
describefromClause ->
source=tThere 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.
Not sure why we supported the syntax of
(SEARCH)? logicalExpression fromClause.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.
search keywords is optional, this is valid query
status=200 source=indexUh oh!
There was an error while loading. Please reload this page.
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.
updated, now the
logicalExpressioncould be both before and aftersource clausewhich is similar to SPL search command.