-
Notifications
You must be signed in to change notification settings - Fork 752
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
Feature: Support DISTINCT in new planner #5410
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
query/src/sql/exec/mod.rs
Outdated
@@ -362,6 +363,12 @@ impl PipelineBuilder { | |||
})?; | |||
} | |||
|
|||
// Since transform has added or did, making group expressions as column expr is safe. | |||
group_expressions = group_expressions |
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 group expression may have been a column, so there may be duplicate conversions here.
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, if a group expression is a column, it is unnecessary here.
The desitnation of adding this code is to make distinct with group-by work.
Two ways to make it better:
- We do this only when it is necessary.
- Move this when bind distinct.
@mergify update |
✅ Branch has been successfully updated |
group_expressions | ||
.iter_mut() | ||
.filter(|expr| matches!(expr, Expression::Column(_)).not()) | ||
.for_each(|expr| *expr = Expression::Column(expr.column_name())); | ||
|
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.
Maybe we can use a iter().filter().map().collect()
instead?
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.
If the original group expression is a column, then it will not be in the collect result.
So the group_expressions count will not be the same as before.
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
Support base
DISTINCT
andDISTINCT
with group by.Changelog
Related Issues
Fixes #5343