Skip to content

Add PartitionEvaluatorArgs to WindowUDFImpl::partition_evaluator #12803

@jcsherin

Description

@jcsherin

Is your feature request related to a problem or challenge?

In BuiltInWindowFunction::{Lead, Lag} to create an instance of PartitionEvaluator directly/indirectly depends on the following being available:

  1. arguments to the window function expression,
  2. the data type of the arguments,
  3. whether IGNORE NULLS is specified,
  4. whether the execution order is reversed.

Currently none of this is available when implementing user-defined window functions.

Describe the solution you'd like

  1. Add PartitionEvaluatorArgs to WindowUDFImpl::partition_evaulator.
pub trait WindowUDFImpl: Debug + Send + Sync {

    /// Invoke the function, returning the [`PartitionEvaluator`] instance
    fn partition_evaluator(
        &self,
        partition_evaluator_args: PartitionEvaluatorArgs,
    ) -> Result<Box<dyn PartitionEvaluator>>;

}
  1. Define PartitionEvaluatorArgs:
/// Defines the state of the user-defined window function during
/// physical execution.
#[derive(Debug, Default)]
pub struct PartitionEvaluatorArgs<'a> {
    /// The expressions passed as arguments to the user-defined window
    /// function.
    input_exprs: &'a [Arc<dyn PhysicalExpr>],
    /// The corresponding data types of expressions passed as arguments
    /// to the user-defined window function.
    input_types: &'a [DataType],
    /// Set to `true` if the user-defined window function is reversed.
    is_reversed: bool,
    /// Set to `true` if `IGNORE NULLS` is specified.
    ignore_nulls: bool,
}

Describe alternatives you've considered

No response

Additional context

Part of #12802.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions