kosiew opened a new pull request, #18798:
URL: https://github.com/apache/datafusion/pull/18798
## Which issue does this PR close?
* Closes #16294.
## 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
hard `NotImplemented` error, preventing several SQLLogicTest cases from running
under round‑trip mode.
Supporting `CUBE` brings consistency with existing `ROLLUP` and `GROUPING
SETS` handling, ensures correct logical plan serialization, and enables
successful execution of tests that rely on cube semantics.
### Before
```
❯ cargo test --test sqllogictests -- --substrait-round-trip grouping.slt:52
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.60s
Running bin/sqllogictests.rs
(target/debug/deps/sqllogictests-917e139464eeea33)
Completed 1 test files in 0 seconds
External error: 1 errors in file
/Users/kosiew/GitHub/datafusion/datafusion/sqllogictest/test_files/grouping.slt
1. query failed: DataFusion error: This feature is not implemented:
GroupingSet CUBE is not yet supported
```
### After
```
❯ cargo test --test sqllogictests -- --substrait-round-trip grouping.slt:52
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.65s
Running bin/sqllogictests.rs
(target/debug/deps/sqllogictests-917e139464eeea33)
Completed 1 test files in 0 seconds
```
## What changes are included in this PR?
* Introduces a shared internal helper `powerset_indices` for efficient
subset generation.
* Refactors `powerset` to use DataFusion error types and removes the
string‑based error.
* Adds a new `powerset_cloned` function for owned‑value subsets needed in
the Substrait adapter.
* Implements full Substrait producer support for `GroupingSet::Cube` using
`powerset_cloned`.
* Updates aggregate Substrait translation to correctly assemble grouping
sets derived from cube expansions.
* Adds a new Substrait round‑trip test case for `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 CUBE` is 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]