Skip to main content

evaluate_window_functions

Function evaluate_window_functions 

Source
pub fn evaluate_window_functions(
    rows: &mut [(String, Value)],
    specs: &[WindowFuncSpec],
) -> Result<(), EvalError>
Expand description

Evaluate window functions over sorted, partitioned rows.

rows is the result set. Each row is a (doc_id, Value::Object). The same rows are mutated in place with window columns appended to each document. A window result keeps NaN and ±Infinity. The row array keeps its input order; each spec’s partitions are ordered by that spec’s own ORDER BY, independent of the row array order.

Unknown window function names must be rejected by the planner before reaching this dispatcher; an unrecognised name here is an internal bug and panics rather than silently dropping the projection.

A division/modulo-by-zero in any PARTITION BY / ORDER BY / argument expression propagates as Err(EvalError::DivisionByZero) rather than folding to NULL.