WindowFunction

Trait WindowFunction 

Source
pub trait WindowFunction: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn signature(&self) -> &str;
    fn compute(
        &self,
        context: &WindowContext,
        row_index: usize,
        args: &[SqlExpression],
        _evaluator: &mut dyn ExpressionEvaluator,
    ) -> Result<DataValue>;

    // Provided methods
    fn transform_window_spec(
        &self,
        base_spec: &WindowSpec,
        _args: &[SqlExpression],
    ) -> Result<WindowSpec> { ... }
    fn validate_args(&self, _args: &[SqlExpression]) -> Result<()> { ... }
}
Expand description

Window function computation trait Each window function receives:

  • The window context (partitions, ordering, frames)
  • The current row index
  • Arguments (column names, parameters)

Required Methods§

Source

fn name(&self) -> &str

Function name (e.g., “MOVING_AVG”)

Source

fn description(&self) -> &str

Description for help system

Source

fn signature(&self) -> &str

Signature for documentation (e.g., “MOVING_AVG(column, window_size)”)

Source

fn compute( &self, context: &WindowContext, row_index: usize, args: &[SqlExpression], _evaluator: &mut dyn ExpressionEvaluator, ) -> Result<DataValue>

Compute the function value for a specific row This is called once per row in the result set

Provided Methods§

Source

fn transform_window_spec( &self, base_spec: &WindowSpec, _args: &[SqlExpression], ) -> Result<WindowSpec>

Optional: Transform/expand the window specification This allows functions to modify the window (e.g., MOVING_AVG sets ROWS n PRECEDING)

Source

fn validate_args(&self, _args: &[SqlExpression]) -> Result<()>

Validate arguments at parse time

Implementors§