You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6ffc45d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(substrait): preserve grouping set output order (apache#23468)
## Which issue does this PR close?
- Closesapache#17910.
## Rationale for this change
For multiple grouping sets, Substrait orders aggregate output as
grouping expressions, measures, then grouping-set ID. DataFusion puts
its internal `__grouping_id` before measures. The consumer applied
`RelCommon.emit` to DataFusion's order, so a mapping such as `[0, 1, 2]`
returned `__grouping_id` where the plan requested its first measure.
See the [Substrait AggregateRel output mapping
specification](https://substrait.io/relations/logical_relations/#aggregate-operation).
## What changes are included in this PR?
- Reorder consumer output to Substrait's direct order before applying
emit mappings.
- Emit a producer mapping back to DataFusion's aggregate order.
- Deduplicate producer grouping expressions used by grouping references.
- Test both issue reproducer and two-measure roundtrip.
## Are these changes tested?
- `cargo test -p datafusion-substrait --features protoc`
- `cargo clippy --all-targets --all-features -- -D warnings`
## Are there any user-facing changes?
Substrait plans with multiple grouping sets now return emitted columns
in specified order. No public API change.
0 commit comments