Skip to content
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

Merged
merged 7 commits into from
May 18, 2022
Merged

Conversation

ygf11
Copy link
Contributor

@ygf11 ygf11 commented May 16, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Support base DISTINCT and DISTINCT with group by.

Changelog

  • New Feature

Related Issues

Fixes #5343

@vercel
Copy link

vercel bot commented May 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) May 17, 2022 at 2:24PM (UTC)

@mergify
Copy link
Contributor

mergify bot commented May 16, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label May 16, 2022
@@ -362,6 +363,12 @@ impl PipelineBuilder {
})?;
}

// Since transform has added or did, making group expressions as column expr is safe.
group_expressions = group_expressions
Copy link
Member

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.

Copy link
Contributor Author

@ygf11 ygf11 May 17, 2022

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:

  1. We do this only when it is necessary.
  2. Move this when bind distinct.

@ygf11
Copy link
Contributor Author

ygf11 commented May 17, 2022

@mergify update

@mergify
Copy link
Contributor

mergify bot commented May 17, 2022

update

✅ Branch has been successfully updated

@ygf11 ygf11 marked this pull request as ready for review May 18, 2022 00:44
@ygf11 ygf11 requested a review from BohuTANG as a code owner May 18, 2022 00:44
@ygf11 ygf11 requested a review from xudong963 May 18, 2022 00:45
@BohuTANG BohuTANG requested review from leiysky and removed request for BohuTANG May 18, 2022 00:48
Comment on lines +370 to +374
group_expressions
.iter_mut()
.filter(|expr| matches!(expr, Expression::Column(_)).not())
.for_each(|expr| *expr = Expression::Column(expr.column_name()));

Copy link
Contributor

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?

Copy link
Contributor Author

@ygf11 ygf11 May 18, 2022

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.

@leiysky leiysky merged commit 2e78aa1 into databendlabs:main May 18, 2022
@ygf11 ygf11 deleted the dev branch May 18, 2022 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Support DISTINCT in new planner
4 participants