refactor(hash-aggr): share one spill context between the spilling aggregate streams - #25538
Open
jayzhan211 wants to merge 2 commits into
Open
jayzhan211 wants to merge 2 commits into
jayzhan211 wants to merge 2 commits into
Conversation
jayzhan211
marked this pull request as ready for review
September 20, 2026 10:26
jayzhan211
marked this pull request as draft
September 20, 2026 10:28
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #25538 +/- ##
==========================================
- Coverage 82.38% 82.38% -0.01%
==========================================
Files 1138 1139 +1
Lines 434491 434297 -194
Branches 434491 434297 -194
==========================================
- Hits 357969 357799 -170
+ Misses 54875 54839 -36
- Partials 21647 21659 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jayzhan211
marked this pull request as ready for review
September 20, 2026 11:38
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?
Rationale for this change
The four grouped aggregation streams that can spill —
FinalHashAggregateStream,SingleHashAggregateStream,OrderedSingleAggregateStreamandOrderedFinalAggregateStream— each define their own spill context (FinalSpillContext,SingleSpillContext,OrderedSingleSpillContext,OrderedFinalSpillContext). The four types have the same seven fields and the same three operations:StreamingMergeBuilderand replay them throughOrderedFinalAggregateStream::new_with_input_and_metrics.The bodies are copies of each other; the only real differences are constructor-time:
Single → Final,group_by.as_final()Single → Final,group_by.as_final()Both axes are functions of values the constructor already receives (
AggregateModeandInputOrderMode), and the natural order is just the ordered-columns-first formula with no ordered columns.What changes are included in this PR?
No behaviour change.
aggregates/spill.rswith a single non-genericAggregateSpill(try_new,has_spills,spill,into_replay_stream). It is non-generic because the only thing a spill needs from a table is the batch returned bytake_state_batch(), so the caller passes that batch in.AggregateSpillinstead."FinalHashAggregateSpill"etc.) and memory consumer names are unchanged. The text of fourinternal_err!messages that cannot be reached by users is now shared.Net: 4 stream files −665 lines, +1 new file of ~235 lines.
This is the first step towards a single spill-replay driver for these streams (see the linked issue), but it stands on its own.
What is the testing strategy for this PR?
Existing tests: the aggregate unit tests in
aggregates/mod.rsandordered_final_stream.rs(spill + replay, OOM, drop/cancel, memory accounting),aggregate_memory_spill.slt,ordered_aggregate_spill.slt, thememory_limitintegration tests and the aggregate fuzz tests. No new tests since there is no new behaviour.Are there any user-facing changes?
No.