-
Couldn't load subscription status.
- Fork 176
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
Conversation
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
| | (SEARCH)? logicalExpression fromClause # searchFilterFrom | ||
| : (SEARCH)? fromClause # searchFrom | ||
| | (SEARCH)? fromClause logicalExpression (logicalExpression)* # searchFromFilter | ||
| | SEARCH logicalExpression fromClause # searchFilterFrom |
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 SEARCH keyword changed to required since the query describe source=t could be ambiguous.
describe source=t should throw syntax error "describe source= <==== .."
But it could be matched to
(SEARCH)? logicalExpression fromClause
logicalExpression -> valueExpr -> fieldExpr -> describe
fromClause -> source=t
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.
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=index
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 logicalExpression could be both before and after source clause which is similar to SPL search command.
searchCommand
: (SEARCH)? (logicalExpression)* fromClause (logicalExpression)* # searchFrom
| | NOT logicalExpression # logicalNot | ||
| | left = logicalExpression (AND)? right = logicalExpression # logicalAnd | ||
| : NOT logicalExpression # logicalNot | ||
| | left = logicalExpression AND right = logicalExpression # logicalAnd |
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 AND will be required in Where expression. But it is still optional in Search filter expression:
source=t a=1 b=c
✅
source=t | where a=1 b=c
❌ (SPL cannot work either)
source=t | where a=1 and b=c
✅
This limitation is because functionArgs could be ambiguous. For example:
source=t | eval f=position('substr' IN 'str')
can be parsed to an incorrect syntax tree:

The correct syntax tree is
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.
LGTM if above 2 limitation are acceptable.
Another concern is that we may not able to push down such filter condition of single field in DSL. But that issue could be addressed in a separate PR.
|
@penghuo this pr did some refactoring on antlr g4 file, could you take another look? There are multiple PPL new command PRs filed, to avoid conflicts, let's complete this refactoring ASAP. |
Signed-off-by: Lantao Jin <ltjin@amazon.com>
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.x
# Create a new branch
git switch --create backport/backport-3849-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 988ab2ea13d533f761558c18c0844c4f206a18d6
# Push it to GitHub
git push --set-upstream origin backport/backport-3849-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.xThen, create a pull request where the |
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-3849-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 988ab2ea13d533f761558c18c0844c4f206a18d6
# Push it to GitHub
git push --set-upstream origin backport/backport-3849-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-devThen, create a pull request where the |
* Support full expression in WHERE clauses Signed-off-by: Lantao Jin <ltjin@amazon.com> * add unit tests Signed-off-by: Lantao Jin <ltjin@amazon.com> * revert typo Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Address comment Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com> (cherry picked from commit 988ab2e)
Description
PPL where clause throws syntax error for:
Related Issues
Resolves #3273, #3272 and #3317
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.