-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Implement Substrait Support for GROUPING SET CUBE
#18798
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
Remove NotImplemented error for GroupingSet::Cube to allow Substrait conversion. Add the generate_powerset function for efficient power set generation using bit-masking. Include validation to manage memory usage and refactor error handling for consistency across GroupingSet variants. Add tests for CUBE queries and validate with SQLLogicTest.
…or index iteration
martin-g
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!
|
@martin-g |
|
@gabotechs |
gabotechs
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.
👍 nice. Left a suggestion about reducing even more the necessary changes, but otherwise LGTM
| let cube_sets = powerset_cloned(set)?; | ||
| cube_sets | ||
| .iter() | ||
| .map(|set| { | ||
| parse_flat_grouping_exprs( | ||
| producer, | ||
| set, | ||
| schema, | ||
| &mut ref_group_exprs, | ||
| ) | ||
| }) | ||
| .collect::<datafusion::common::Result<Vec<_>>>() |
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.
Any opinions on just using the normal powerset() function here instead of creating a *_cloned() variant? handling the clone here should be trivial:
- let cube_sets = powerset_cloned(set)?;
+ let cube_sets = powerset(set)?;
cube_sets
.iter()
.map(|set| {
parse_flat_grouping_exprs(
producer,
- set,
+ &set.iter().map(|v| (*v).clone()).collect::<Vec<_>>(),
schema,
&mut ref_group_exprs,
)
})And that would avoid maintaining 3 function signatures (powerset, powerset_cloned and powerset_indices)
…nce in grouping expressions
…ble from the substrait module.
|
@gabotechs |
Which issue does this PR close?
Rationale for this change
This change adds complete Substrait round‑trip support for
GROUPING SET CUBE, allowing logical plans containing cubes to successfully convert to and from Substrait. Previously, cube handling in the Substrait producer returned a hardNotImplementederror, preventing several SQLLogicTest cases from running under round‑trip mode.Supporting
CUBEbrings consistency with existingROLLUPandGROUPING SETShandling, ensures correct logical plan serialization, and enables successful execution of tests that rely on cube semantics.Before
After
What changes are included in this PR?
powerset_indicesfor efficient subset generation.powersetto use DataFusion error types and removes the string‑based error.powerset_clonedfunction for owned‑value subsets needed in the Substrait adapter.GroupingSet::Cubeusingpowerset_cloned.GROUP BY CUBE.Are these changes tested?
Yes. A new Substrait round‑trip test (
aggregate_grouping_cube) validates the logical plan after translation. Existing grouping/aggregate tests continue to pass, covering other grouping‑set variants.Are there any user-facing changes?
There are no user‑facing API changes. The behavior of
GROUP BY CUBEis now consistent under Substrait round‑trip mode, which may allow previously failing queries to succeed.LLM-generated code disclosure
This PR includes LLM‑generated code and comments. All LLM‑generated content has been manually reviewed and tested.