refactor(hash-aggr): route grouping sets to the migrated hash streams - #24870
Open
2010YOUY01 wants to merge 1 commit into
Open
refactor(hash-aggr): route grouping sets to the migrated hash streams#248702010YOUY01 wants to merge 1 commit into
2010YOUY01 wants to merge 1 commit into
Conversation
`GROUPING SETS` / `CUBE` / `ROLLUP` still fell back to the legacy `GroupedHashAggregateStream`, because the migrated partial and single stream predicates required a plain `GROUP BY`. Grouping sets are always planned with `InputOrderMode::Linear` since apache#24422, and the shared `AggregateHashTable` already expands every grouping set of an input batch, so they can run on `PartialHashAggregateStream` and `SingleHashAggregateStream`. - Move `init_empty_grouping_sets` from the partial table into the shared table, so single aggregation also emits the grand-total group on empty input. - Drop the `is_single()` condition from the partial and single stream predicates. The final and partial-reduce predicates keep it, because state-input stages must receive the expanded keys as a plain group by. - The spill-mode `check_grouping_sets` snapshot changes because the migrated partial stream flushes after every batch under memory pressure; the final results are unchanged. Part of apache#22710 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2010YOUY01
commented
Sep 2, 2026
| | 3 | | 1 | 1 | | ||
| | 3 | | 1 | 2 | | ||
| | 3 | 2.0 | 0 | 2 | | ||
| | 3 | 2.0 | 0 | 1 | |
Contributor
Author
There was a problem hiding this comment.
Both are valid outputs for partial aggregation with early emit; the difference is because execution is not 100% the same between the legacy and refactored implementations.
Contributor
There was a problem hiding this comment.
just wondering in case of distinct and regular aggregation, usually dedup should be on the partial stage?
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24870 +/- ##
==========================================
- Coverage 81.61% 81.61% -0.01%
==========================================
Files 1123 1123
Lines 409562 409634 +72
Branches 409562 409634 +72
==========================================
+ Hits 334284 334341 +57
- Misses 55647 55655 +8
- Partials 19631 19638 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #22710
Rationale for this change
Let aggregate with grouping sets get route into the newly refactored aggregation (see above EPIC for backgrounds)
What changes are included in this PR?
The key change is at datafusion/physical-plan/src/aggregates/mod.rs, it changes the planning decision as described above
What is the testing strategy for this PR?
Existing tests.
Are there any user-facing changes?
No