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

   ## Summary
   
   Follow-up to #24007 that adopts the API shape Daniël suggested in review: 
instead of the exec owning per-partition state behind `Arc<[Mutex<_>]>` + a 
getter, accept an observer callback and let the caller own the storage.
   
   The exec becomes a pure event source. Deleted (relative to #24007): 
`FinalStateSlot`, the Empty/Single/Multi state machine, 
`finalized_partition_state` getter, both error branches, the mutex, and the 
\"at most one PARTITION BY group\" doctrine — multi-group handling is now the 
caller's.
   
   ## API (matches the suggestion verbatim)
   
   ```rust
   // physical-plan/src/windows/bounded_window_agg_exec.rs
   pub type FinalizedWindowStateObserver = Arc<
       dyn Fn(usize, &PartitionKey, &[Option<Vec<ScalarValue>>]) -> Result<()>
           + Send + Sync,
   >;
   
   impl BoundedWindowAggExec {
       pub fn with_finalized_state_observer(mut self, obs: 
FinalizedWindowStateObserver) -> Self { … }
   }
   
   // physical-expr/src/window/window_expr.rs
   impl WindowState {
       /// `Accumulator::state()` if this is an aggregate window function, 
`None` otherwise.
       pub fn aggregate_state(&mut self) -> Result<Option<Vec<ScalarValue>>> { 
… }
   }
   ```
   
   No `pub use WindowFn` — the state is read through a method on the 
already-public `WindowState`, so the internal enum stays private.
   
   ## Write site
   
   Top of `prune_state`, before both retains. `WindowAggState::is_end` is 
copied from `PartitionBatchState::is_end` during `evaluate_stateful`, so every 
window_expr's state map agrees on which keys have closed; iterating the first 
map is sufficient.
   
   ## Test plan
   
   - [x] `cargo test -p datafusion-physical-plan --lib windows::` — 11 pass 
including new `test_finalized_state_observer_fires_at_partition_close`
   - [x] `cargo clippy --all-targets -p datafusion-physical-plan -p 
datafusion-physical-expr` — clean
   - [x] `cargo fmt --all` — clean
   
   Cross-refs: closes the review thread on #24007.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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