-
Notifications
You must be signed in to change notification settings - Fork 600
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
feat(frontend): support filter clause in aggregation #3626
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3626 +/- ##
==========================================
+ Coverage 74.38% 74.40% +0.02%
==========================================
Files 781 781
Lines 110682 110786 +104
==========================================
+ Hits 82330 82433 +103
- Misses 28352 28353 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
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.
generally LGTM. the planner tests are comprehensive, good work!
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
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.
should check if exist aggregation in the filter clause.
test on PG:
dev=# explain select max(v2) filter(where min(v3) > 1.0) from test group by v1;
ERROR: aggregate functions are not allowed in FILTER
LINE 1: explain select max(v2) filter(where min(v3) > 1.0) from test...
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
…3626) * parse filter in agg * bind selective agg * fix filter clause input ref index * fix logical agg column prune * modify parser test, add filter * fmt code * remove unused struct * add more tests and error reporting * add test for non-agg filter clause * add group by test * fix `rewrite_with_input` * fix 2 phase agg * report error for agg calls in the filter clause Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.
What's changed and what's your intention?
Summarize your change
This PR adds selective aggregation support to the frontend.
How does this PR work?
To parse the selective aggregation syntax, the parser, the binder, and the
logical_agg
plan node have been changed.LogicalAgg
is changed as well to preserve columns that are referred to by the filter clause.partial_agg
needsfilter
.Limitations of the Current Code
sqlsmith
is changed as well. But currently, it can only generate aggregation functions without any filter.is_in_filter_clause
is added inLogicalAggBuilder
because the filter clause can refer to any columns while other places can only refer to group keys. So I add this field to distinguish between them. IMO the current implementation is kind of dirty.Checklist
./risedev check
(or alias,./risedev c
)TODO
rewrite_with_input
Refer to a related PR or issue link (optional)
Tracking in #3589, RFC #3506
Future works
After adding selective aggregation in the frontend, I will continue working to add this function to the executors.