pub trait BuiltInWindowFunctionExpr: Send + Sync + Debug {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn field(&self) -> Result<Field>;
    fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>>;
    fn create_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>>;

    // Provided methods
    fn name(&self) -> &str { ... }
    fn evaluate_args(&self, batch: &RecordBatch) -> Result<Vec<ArrayRef>> { ... }
    fn reverse_expr(&self) -> Option<Arc<dyn BuiltInWindowFunctionExpr>> { ... }
    fn get_result_ordering(
        &self,
        _schema: &SchemaRef
    ) -> Option<PhysicalSortExpr> { ... }
}
Expand description

Evaluates a window function by instantiating a [PartitionEvaluator] for calculating the function’s output in that partition.

Note that unlike aggregation based window functions, some window functions such as rank ignore the values in the window frame, but others such as first_value, last_value, and nth_value need the value.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Returns the aggregate expression as Any so that it can be downcast to a specific implementation.

source

fn field(&self) -> Result<Field>

The field of the final result of evaluating this window function.

source

fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>>

Expressions that are passed to the PartitionEvaluator.

source

fn create_evaluator(&self) -> Result<Box<dyn PartitionEvaluator>>

Create a PartitionEvaluator for evaluating the function on a particular partition.

Provided Methods§

source

fn name(&self) -> &str

Human readable name such as "MIN(c2)" or "RANK()". The default implementation returns placeholder text.

source

fn evaluate_args(&self, batch: &RecordBatch) -> Result<Vec<ArrayRef>>

Evaluate window function’s arguments against the input window batch and return an ArrayRef.

Typically, the resulting vector is a single element vector.

source

fn reverse_expr(&self) -> Option<Arc<dyn BuiltInWindowFunctionExpr>>

Construct a new BuiltInWindowFunctionExpr that produces the same result as this function on a window with reverse order. The return value of this function is used by the DataFusion optimizer to avoid re-sorting the data when possible.

Returns None (the default) if no reverse is known (or possible).

For example, the reverse of lead(10) is lag(10).

source

fn get_result_ordering(&self, _schema: &SchemaRef) -> Option<PhysicalSortExpr>

Returns the ordering introduced by the window function, if applicable. Most window functions don’t introduce an ordering, hence the default value is None. Note that this information is used to update ordering equivalences.

Implementors§