Skip to content

test: add regression coverage for terminal hash aggregate drain - #24853

Open
hhhizzz wants to merge 1 commit into
apache:mainfrom
hhhizzz:test/issue-24849-terminal-hash-aggregate-drain
Open

test: add regression coverage for terminal hash aggregate drain#24853
hhhizzz wants to merge 1 commit into
apache:mainfrom
hhhizzz:test/issue-24849-terminal-hash-aggregate-drain

Conversation

@hhhizzz

@hhhizzz hhhizzz commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#23182 fixed a performance regression in terminal hash aggregate output by avoiding repeated destructive EmitTo::First calls. However, the remaining MaterializedAggregateOutput unit test only exercises the slicing helper and does not verify the behavior through AggregateExec.

A result-only integration test would pass with both the regressed and fixed implementations, while a wall-clock assertion would be unreliable in CI. This PR therefore uses a test GroupsAccumulator that returns an error if terminal output falls back to destructive EmitTo::First.

What changes are included in this PR?

  • Adds single_grouped_aggregate_avoids_destructive_terminal_drain, which runs unordered Single hash aggregation with more groups than the configured batch_size.
  • Verifies that AggregateExec selects SingleHash, emits multiple bounded batches, and returns the correct aggregate results for repeated group keys.
  • Extends the test accumulator with preserving evaluation and state support so the regression test remains compatible with future direct blocked or chunked output implementations.
  • Keeps the test independent of MaterializedAggregateOutput; Single and Final hash aggregation exercise the same terminal drain helper.

What is the testing strategy for this PR?

  • Verified that temporarily restoring destructive EmitTo::First(batch_size) causes the new test to fail with the expected accumulator error, while the current implementation passes.
  • Applied an equivalent FinalHash accumulator oracle to the historical regression: it fails on d58e0c6d4^ and passes on d58e0c6d4. The migrated SingleHash stream did not exist at that historical revision.
  • Ran cargo fmt --all.
  • Ran cargo clippy --all-targets --all-features -- -D warnings.
  • Ran the extended workspace test suite with avro,json,backtrace,extended_tests,recursive_protection,parquet_encryption; all tests passed after initializing the required Arrow and Parquet test fixtures.

Are there any user-facing changes?

No. This PR only adds regression test coverage.

@github-actions github-actions Bot added documentation Improvements or additions to documentation physical-plan Changes to the physical-plan crate labels Sep 1, 2026
@hhhizzz
hhhizzz force-pushed the test/issue-24849-terminal-hash-aggregate-drain branch from 40b6be7 to 3a614fd Compare September 1, 2026 15:35
@github-actions github-actions Bot removed the documentation Improvements or additions to documentation label Sep 1, 2026
@hhhizzz
hhhizzz marked this pull request as ready for review September 1, 2026 16:14
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.59%. Comparing base (07483c1) to head (3a614fd).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/physical-plan/src/aggregates/mod.rs 55.55% 25 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24853      +/-   ##
==========================================
+ Coverage   81.58%   81.59%   +0.01%     
==========================================
  Files        1123     1123              
  Lines      408215   408970     +755     
  Branches   408215   408970     +755     
==========================================
+ Hits       333034   333705     +671     
- Misses      55613    55653      +40     
- Partials    19568    19612      +44     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Add integration regression test for terminal hash aggregate drain

2 participants