Skip to content

fix: account for struct memory when emitting min/max groups - #26894

Closed
efegokdemir wants to merge 1 commit into
apache:mainfrom
efegokdemir:efe/datafusion-minmax-memory-accounting
Closed

efegokdemir wants to merge 1 commit into
apache:mainfrom
efegokdemir:efe/datafusion-minmax-memory-accounting

Conversation

@efegokdemir

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Ordered aggregation emits groups incrementally, but MinMaxStructState::emit_to(EmitTo::First(n)) subtracts row counts from a byte counter. Emitted struct memory therefore remains counted, which can cause valid queries to exhaust the memory pool.

What changes are included in this PR?

Subtract the memory size of each emitted struct and add a regression test for the emitted byte count and remaining state size.

What is the testing strategy for this PR?

  • cargo test --locked -p datafusion-functions-aggregate --lib (267 passed).
  • cargo fmt --all -- --check and workspace Clippy with all targets and features passed.
  • The full extended workspace test command passed, including the DataFusion library tests, extended tests, and 543 SQL logic test files.

Are there any user-facing changes?

Yes. Ordered aggregation no longer overcounts memory for emitted struct values. There are no public API changes.

@github-actions github-actions Bot added the functions Changes to functions implementation label Oct 29, 2026
@alamb alamb added the Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days label Oct 29, 2026
@alamb

alamb commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution! I am closing this under DataFusion's AI Dump policy.

https://datafusion.apache.org/contributor-guide/ai-policy.html#what-is-an-ai-dump-and-why-it-is-not-helpful

Review capacity is very limited and this is a PR opened within hours of its issue with a testing section built around command runs and pass counts, from an author flagged for opening multiple PRs in a short time. The policy asks new contributors to work with maintainers on one PR at a time rather than opening several at once.

If this fix matters to you, please pick the single change you care most about, reopen or resubmit it with a short description in your own words, and we are happy to help with review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MinMaxStructState::emit_to(EmitTo::First(n)) subtracts row counts from a byte counter

2 participants