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

Add ROLLUP and GROUPING SETS substrait support #7382

Merged
merged 4 commits into from
Aug 29, 2023

Conversation

nseekhao
Copy link
Contributor

Which issue does this PR close?

Closes #7381 .

Rationale for this change

To add support for aggregation with ROLLUP and GROUPING SETS.

What changes are included in this PR?

  • Producer: Expr::GroupingSet to substrait::proto::aggregate_rel::Grouping
    • Both Rollup gets expanded into equivalent grouping sets, since Substrait doesn't have a dedicated type for ROLLUP
    • Cube is not yet supported
  • Consumer: substrait::proto::aggregate_rel::Grouping to Expr::GroupingSet
  • Tests: grouping sets, rollup

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

No.

@alamb alamb requested a review from waynexia August 23, 2023 18:18
@alamb alamb changed the title Add ROLLUP and GROUPING SETS support Add ROLLUP and GROUPING SETS substrait support Aug 23, 2023
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

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

Thanks for this @nseekhao

async fn aggregate_grouping_rollup() -> Result<()> {
assert_expected_plan(
"SELECT a, c, e, avg(b) FROM data GROUP BY ROLLUP (a, c, e)",
"Aggregate: groupBy=[[GROUPING SETS ((data.a, data.c, data.e), (data.a, data.c), (data.a), ())]], aggr=[[AVG(data.b)]]\
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines 535 to 537
for i in 0..set.len() {
sets.push(set[..=i].to_vec());
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks great. It generates the same result (after .rev()) with create_rollup_physical_expr

@alamb
Copy link
Contributor

alamb commented Aug 29, 2023

I merged this branch up from `main to resolve a conflict. I hope to merge it when CI completes

@alamb alamb merged commit 85ec314 into apache:main Aug 29, 2023
@andygrove andygrove added the enhancement New feature or request label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request substrait
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Substrait: ROLLUP and GROUPING SETS support
4 participants