Skip to content

Conversation

@RinChanNOWWW
Copy link
Contributor

@RinChanNOWWW RinChanNOWWW commented Mar 13, 2023

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

Summary

Basic implementation of GROUP BY GROUPING SETS.

Main idea:

Add a new PhysicalPlan: PhysicalPlan::AggregateExpand and its corresponding Transform: TransformExpandGroupingSets.

If the query is a GROUP BY GROUPING SETS clause, PhysicalPlan::AggregateExpand will be added to the front of PhysicalPlan::AggregatePartial. And the plan will be built into TransformExpandGroupingSets.

TransformExpandGroupingSets will expand the input DataBlock for each grouping set. It will fill NULLs if the group-by columns are not found in the grouping set.

Tacking in #10492

@vercel
Copy link

vercel bot commented Mar 13, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated
databend ⬜️ Ignored (Inspect) Mar 15, 2023 at 4:42AM (UTC)

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 13, 2023
@RinChanNOWWW RinChanNOWWW force-pushed the grouping-sets branch 6 times, most recently from 580e272 to 3f6ffc8 Compare March 14, 2023 12:45
@RinChanNOWWW RinChanNOWWW requested review from andylokandy, leiysky, sundy-li and xudong963 and removed request for andylokandy March 14, 2023 12:46
@RinChanNOWWW RinChanNOWWW marked this pull request as ready for review March 14, 2023 12:51
@sundy-li
Copy link
Member

TransformExpandGroupingSets will expand the input DataBlock for each grouping set. It will fill NULLs if the group-by columns are not found in the grouping set.

What if the original column has nulls? Seem they share the same hashmap here.

@RinChanNOWWW
Copy link
Contributor Author

What if the original column has nulls? Seem they share the same hashmap here.

There are the same when grouping.

We can distinguish this two kinds of NULLs by aggregate function grouping.

If grouping sets make it become NULL, grouping will return 1, else 0.

grouping will be implemented in later PR.

Copy link
Member

@sundy-li sundy-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest Looks good to me.

@RinChanNOWWW
Copy link
Contributor Author

image

cc @BohuTANG

@BohuTANG BohuTANG merged commit d250f81 into databendlabs:main Mar 15, 2023
@RinChanNOWWW RinChanNOWWW deleted the grouping-sets branch March 15, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants