wirybeaver opened a new pull request, #22947:
URL: https://github.com/apache/datafusion/pull/22947

   ## Which issue does this PR close?
   
   Closes #22946.
   
   ## Rationale for this change
   
   `WindowAggExec` currently buffers input for window partition evaluation in 
memory. Large or skewed window partitions can exhaust the memory pool even when 
DataFusion is configured with spill storage, making window queries less robust 
than other spill-aware physical operators.
   
   ## What changes are included in this PR?
   
   This PR adds spill support to `WindowAggExec` while preserving the existing 
sorted-partition execution model:
   
   - Registers a spill-capable `MemoryConsumer` for each `WindowAggStream` 
partition.
   - Tracks the active window partition separately from completed partitions.
   - Buffers rows by partition key and emits each completed partition 
independently instead of waiting for all input to finish.
   - Spills active partition batches through the existing `SpillManager` when 
memory reservation growth fails and a disk manager is configured.
   - Reads spilled partitions back before computing window expressions.
   - Releases memory reservations after each in-memory or spilled partition is 
evaluated.
   - Surfaces a more specific OOM context when spilling is unavailable or the 
partition still cannot be materialized for evaluation.
   - Reports standard spill metrics through `SpillMetrics`.
   
   ## Are these changes tested?
   
   Yes. Added focused unit coverage for:
   
   - spilling a partition that crosses input batch boundaries;
   - avoiding spill when memory is sufficient;
   - returning a resources-exhausted error when memory is constrained and the 
disk manager is disabled;
   - preserving empty-input behavior.
   
   Locally verified after rebasing onto `apache/datafusion/main`:
   
   ```text
   /home/user/.cargo/bin/cargo fmt --check
   /home/user/.cargo/bin/cargo test -p datafusion-physical-plan window_agg_exec 
--lib
   
   running 8 tests
   ...
   test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 1474 filtered 
out; finished in 2.10s
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to