-
Notifications
You must be signed in to change notification settings - Fork 180
Support count(eval) expression with stats command
#4103
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
Support count(eval) expression with stats command
#4103
Conversation
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
penghuo
left a comment
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.
Current solution push down count(eval(p)) as script expression? we plan to agg-filter push down in future PR?
I think filtered aggregation pushdown is reverted in PR #4002. I'm working on a follow up PR to reenable it correctly. |
RyanL1997
left a comment
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.
Hi @dai-chen , thanks for taking this on. LGTM and I just left a question.
ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java
Show resolved
Hide resolved
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
| * Fluent API for building count(eval) test cases. Provides a clean and readable way to define PPL | ||
| * queries and their expected outcomes. | ||
| */ | ||
| protected PPLQueryTestBuilder withPPLQuery(String ppl) { |
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.
nice!
|
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-4103-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 29c8b72148ba9a46de4d16bd4383eca25c520ffd
# Push it to GitHub
git push --set-upstream origin backport/backport-4103-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 |
* Rewrite count(eval) expression to support filtered counting Signed-off-by: Chen Dai <[email protected]> * Refactor count eval UTs Signed-off-by: Chen Dai <[email protected]> * Add count eval ITs Signed-off-by: Chen Dai <[email protected]> * Add count eval doctest Signed-off-by: Chen Dai <[email protected]> * Fix doctest failure Signed-off-by: Chen Dai <[email protected]> * Add more UT for AST builder Signed-off-by: Chen Dai <[email protected]> * Resolve conflicts and more changes for shortcut c Signed-off-by: Chen Dai <[email protected]> --------- Signed-off-by: Chen Dai <[email protected]> (cherry picked from commit 29c8b72) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
This PR introduces support for
count(eval(condition))function in PPLstatscommand which enables filtered counting capability. Pushdown optimization and additional support fordistinct_count(eval)andeventstatscommand (low priority) will be worked on next. Please find more details in issue below: #3949 (comment).Key implementation decisions:
count(eval(...))is rewritten ascount(CASE WHEN ... THEN 1 ELSE NULL END).countaggregation is supported (distinct_countis planned next). Support for other aggregation functions may be added in the future if the semantic is clear.Related Issues
Resolves (partially) #3949
Check List
--signoffor-s.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.