pub trait WindowStateObserver: Send + Sync {
// Required method
fn finalize_window_aggregate(
&self,
partition_idx: usize,
window_expr: &Arc<dyn WindowExpr>,
partition_key: &PartitionKey,
state: Vec<ScalarValue>,
) -> Result<()>;
}Expand description
Callback receiver for per-partition window state.
state is the result of Accumulator::state, which is a &mut self
call whose trait doc states “this function should not be called twice.”
Several built-in aggregates (median, percentile_cont, string_agg,
min_max_bytes/min_max_struct) std::mem::take their internal
buffers to build that state — so state is a destructive read, not a
snapshot. The exec fires this at most once per group; a callee that
needs the value beyond the callback must retain it (e.g. clone into
owned storage).
Required Methods§
Sourcefn finalize_window_aggregate(
&self,
partition_idx: usize,
window_expr: &Arc<dyn WindowExpr>,
partition_key: &PartitionKey,
state: Vec<ScalarValue>,
) -> Result<()>
fn finalize_window_aggregate( &self, partition_idx: usize, window_expr: &Arc<dyn WindowExpr>, partition_key: &PartitionKey, state: Vec<ScalarValue>, ) -> Result<()>
Invoked once per (output-partition-index, window-expression,
PARTITION BY tuple) as each PARTITION BY group closes, for every
aggregate window expression on the exec. Non-aggregate window
functions (e.g. row_number, rank, lead/lag) do not fire this
callback.
§Arguments
partition_idx- Output partition index of theBoundedWindowAggExecstream firing this callback.window_expr- The window expression whose state just closed.partition_key- The PARTITION BY tuple that just closed.state-Accumulator::statefor the closed group ofwindow_expr. See the trait-level doc for the destructive-read contract.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".