Skip to content

refactor(hash-aggr): Support spilling for single mode aggregation - #23965

Open
2010YOUY01 wants to merge 1 commit into
apache:mainfrom
2010YOUY01:split-aggr-spill-single
Open

refactor(hash-aggr): Support spilling for single mode aggregation#23965
2010YOUY01 wants to merge 1 commit into
apache:mainfrom
2010YOUY01:split-aggr-spill-single

Conversation

@2010YOUY01

@2010YOUY01 2010YOUY01 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #22710

Rationale for this change

This PR implements larger-than-memory execution for single mode aggregation.

See top comments at single_stream.rs for the high-level idea. The key implementations are in the same file.

What changes are included in this PR?

Are these changes tested?

Existing tests.

  • todo for myself: double check the codecov

Are there any user-facing changes?

No

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Jul 29, 2026
Field::new("b", DataType::Float64, false),
]));

let group_keys = [2, 3, 4, 4].repeat(1_000);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old implementation set a very tight memory budget, and the refactored implementation might have minor implementation difference, making this test fail.

Here it just try to scale up the test input size and memory limit, the test target is the same.

async fn test_aggregate_with_spill_if_necessary() -> Result<()> {
// test with spill
run_test_with_spill_pool_if_necessary(2_000, true).await?;
run_test_with_spill_pool_if_necessary(20_000, true).await?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the same as the previous note on test change.

matches!(root, DataFusionError::ResourcesExhausted(_)),
"Expected ResourcesExhausted, got: {root}",
);
let msg = root.to_string();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above check on error type is enough I think, here it also assert the exact error message

/// See comments at `poll_next()` for details.
///
/// Returns the next operator state with control flow decision.
fn handle_producing_output(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has no functional changes, the diffs are

  1. use internal_err instead of assert
  2. simplify some control flow code with break_with_err

SET datafusion.execution.target_partitions = 1

statement ok
SET datafusion.execution.batch_size = 128

@2010YOUY01 2010YOUY01 Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the above notes on the test change #23965 (comment)

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 sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant