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§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Description for help system
Sourcefn signature(&self) -> &str
fn signature(&self) -> &str
Signature for documentation (e.g., “MOVING_AVG(column, window_size)”)
Sourcefn compute(
&self,
context: &WindowContext,
row_index: usize,
args: &[SqlExpression],
_evaluator: &mut dyn ExpressionEvaluator,
) -> Result<DataValue>
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§
Sourcefn transform_window_spec(
&self,
base_spec: &WindowSpec,
_args: &[SqlExpression],
) -> Result<WindowSpec>
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)
Sourcefn validate_args(&self, _args: &[SqlExpression]) -> Result<()>
fn validate_args(&self, _args: &[SqlExpression]) -> Result<()>
Validate arguments at parse time