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§
Sourcefn get_accumulator(&self) -> Result<Box<dyn Accumulator>>
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.
Sourcefn filter_expr(&self) -> Option<&Arc<dyn PhysicalExpr>>
fn filter_expr(&self) -> Option<&Arc<dyn PhysicalExpr>>
Optional FILTER (WHERE …) predicate for this window aggregate.
Sourcefn 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 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.
Sourcefn is_constant_in_partition(&self) -> bool
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§
Sourcefn aggregate_evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef>
fn aggregate_evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef>
Evaluates the window function against the batch.
Sourcefn aggregate_evaluate_stateful(
&self,
partition_batches: &PartitionBatches,
window_agg_state: &mut PartitionWindowAggStates,
) -> Result<()>
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.
Sourcefn 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>
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 (seePartitionBatchState).most_recent_row: the batch that contains the most recent row, if available (seePartitionBatchState).last_range: The last range of rows that were processed (seeWindowAggState).window_frame_ctx: Details about the window frame (seeWindowFrameContext).idx: The index of the current row in the record batch.not_end: is the current row not the end of the partition (seePartitionBatchState).