Skip to content

fix: spill final hash aggregate output when the pool refuses it - #26734

Draft
yashaggarwal85d wants to merge 1 commit into
apache:mainfrom
yashaggarwal85d:fix-final-hash-aggregate-output-spill
Draft

yashaggarwal85d wants to merge 1 commit into
apache:mainfrom
yashaggarwal85d:fix-final-hash-aggregate-output-spill

Conversation

@yashaggarwal85d

@yashaggarwal85d yashaggarwal85d commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

FinalHashAggregateStream fails with ResourcesExhausted when the materialized output is bigger than the table it came from (e.g. string_agg) and the pool won't grow the reservation. The other streams carry on.

What changes are included in this PR?

When that resize is refused and temp files are enabled, the stream writes the materialized output to one spill file, drops it, frees the reservation and streams the batches back. Without temp files it still errors, now with a message saying it couldn't spill the output.

What is the testing strategy for this PR?

Updated the Final case in output_materialization_refused (from #26562): it now spills once and returns all 256 rows in 4 batches. Aggregate unit tests and the aggregate slt files pass.

Are there any user-facing changes?

No, queries that hit this now succeed instead of erroring.


This was AI-assisted, I've reviewed the changes myself.

@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Final hash aggregate fails with ResourcesExhausted when its materialized output is larger than its table

1 participant