-
Notifications
You must be signed in to change notification settings - Fork 706
feat(frontend): BatchAgg and StreamAgg #1026
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
fuyufjh
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.
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.
I think it's not correct. The input need to be distributed by group key
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.
Similarly, SimpleAgg needs input to be distributed in singoton
rust/frontend/src/planner/select.rs
Outdated
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.
What if select has group by but no agg function within select items?
create table t (a char(10), b int, c bool);
select t.a from t group by t.c;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.
This query is invalid....
postgres=# select t.a from t group by t.c;
ERROR: column "t.a" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: select t.a from t group by t.c;
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.
Yes, so are we able to prompt error on this sql?
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.
Yes, we can.
dev=> select v1 from t group by v2;
ERROR: Invalid input syntax: column must appear in the GROUP BY clause or be used in an aggregate function
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.
We can add some error cases in the planner test, although they are already covered by unit tests of LogicalAgg::create.
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.
Let's be more compact and follow expr::AggCall:
let mut builder = f.debug_tuple(&format!("{:?}", self.agg_kind));
self.inputs.iter().for_each(|child| {
builder.field(child);
});
builder.finish()
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.
nit: groups before aggs
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.
typo: to_stream
xiangjinwu
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.
rest 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.
The output distribution of HashAgg and SimpleAgg are also by-groups and Single respectively.
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.
Similar to logical, groups before aggs.
rust/frontend/src/planner/select.rs
Outdated
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.
We can add some error cases in the planner test, although they are already covered by unit tests of LogicalAgg::create.
Codecov Report
@@ Coverage Diff @@
## main #1026 +/- ##
============================================
+ Coverage 71.39% 71.50% +0.11%
Complexity 2766 2766
============================================
Files 978 982 +4
Lines 57782 57936 +154
Branches 1790 1790
============================================
+ Hits 41254 41430 +176
+ Misses 15637 15615 -22
Partials 891 891
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 |
* add group_by for BoundSelect. * plan agg. * add tests. * fix
9## What's changed and what's your intention?
PLEASE DO NOT LEAVE THIS EMPTY !!!
Please explain IN DETAIL what the changes are in this PR and why they are needed:
In this pr, I TRY to add four physical aggs, but I'm not sure I've got the right solution.
Checklist
Refer to a related PR or issue link (optional)
close #929
close #943