AggregateWindowExpr

Trait AggregateWindowExpr 

Source
pub trait AggregateWindowExpr: WindowExpr {
    // Required methods
    fn get_accumulator(&self) -> Result<Box<dyn Accumulator>>;
    fn filter_expr(&self) -> Option<&Arc<dyn PhysicalExpr>>;
    fn get_aggregate_result_inside_range(
        &self,
        last_range: &Range<usize>,
        cur_range: &Range<usize>,
        value_slice: &[ArrayRef],
        accumulator: &mut Box<dyn Accumulator>,
        filter_mask: Option<&BooleanArray>,
    ) -> Result<ScalarValue>;
    fn is_constant_in_partition(&self) -> bool;

    // Provided methods
    fn aggregate_evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef> { ... }
    fn aggregate_evaluate_stateful(
        &self,
        partition_batches: &PartitionBatches,
        window_agg_state: &mut PartitionWindowAggStates,
    ) -> Result<()> { ... }
    fn get_result_column(
        &self,
        accumulator: &mut Box<dyn Accumulator>,
        record_batch: &RecordBatch,
        most_recent_row: Option<&RecordBatch>,
        last_range: &mut Range<usize>,
        window_frame_ctx: &mut WindowFrameContext,
        idx: usize,
        not_end: bool,
    ) -> Result<ArrayRef> { ... }
}
Expand description

Extension trait that adds common functionality to AggregateWindowExprs

Required Methods§

Source

fn get_accumulator(&self) -> Result<Box<dyn Accumulator>>

Get the accumulator for the window expression. Note that distinct window expressions may return distinct accumulators; e.g. sliding (non-sliding) expressions will return sliding (normal) accumulators.

Source

fn filter_expr(&self) -> Option<&Arc<dyn PhysicalExpr>>

Optional FILTER (WHERE …) predicate for this window aggregate.

Source

fn get_aggregate_result_inside_range( &self, last_range: &Range<usize>, cur_range: &Range<usize>, value_slice: &[ArrayRef], accumulator: &mut Box<dyn Accumulator>, filter_mask: Option<&BooleanArray>, ) -> Result<ScalarValue>

Given current range and the last range, calculates the accumulator result for the range of interest.

Source

fn is_constant_in_partition(&self) -> bool

Indicates whether this window function always produces the same result for all rows in the partition.

Provided Methods§

Source

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

Evaluates the window function against the batch.

Source

fn aggregate_evaluate_stateful( &self, partition_batches: &PartitionBatches, window_agg_state: &mut PartitionWindowAggStates, ) -> Result<()>

Statefully evaluates the window function against the batch. Maintains state so that it can work incrementally over multiple chunks.

Source

fn get_result_column( &self, accumulator: &mut Box<dyn Accumulator>, record_batch: &RecordBatch, most_recent_row: Option<&RecordBatch>, last_range: &mut Range<usize>, window_frame_ctx: &mut WindowFrameContext, idx: usize, not_end: bool, ) -> Result<ArrayRef>

Calculates the window expression result for the given record batch. Assumes that record_batch belongs to a single partition.

§Arguments
  • accumulator: The accumulator to use for the calculation.
  • record_batch: batch belonging to the current partition (see PartitionBatchState).
  • most_recent_row: the batch that contains the most recent row, if available (see PartitionBatchState).
  • last_range: The last range of rows that were processed (see WindowAggState).
  • window_frame_ctx: Details about the window frame (see WindowFrameContext).
  • idx: The index of the current row in the record batch.
  • not_end: is the current row not the end of the partition (see PartitionBatchState).

Implementors§