pub struct WindowContext { /* private fields */ }Expand description
Context for evaluating window functions
Implementations§
Source§impl WindowContext
impl WindowContext
Sourcepub fn new(
view: Arc<DataView>,
partition_by: Vec<String>,
order_by: Vec<OrderByItem>,
) -> Result<Self>
pub fn new( view: Arc<DataView>, partition_by: Vec<String>, order_by: Vec<OrderByItem>, ) -> Result<Self>
Create a new window context with partitioning and ordering
Sourcepub fn new_with_spec(view: Arc<DataView>, spec: WindowSpec) -> Result<Self>
pub fn new_with_spec(view: Arc<DataView>, spec: WindowSpec) -> Result<Self>
Create a new window context with a full window specification
Sourcepub fn get_offset_value(
&self,
current_row: usize,
offset: i32,
column: &str,
) -> Option<DataValue>
pub fn get_offset_value( &self, current_row: usize, offset: i32, column: &str, ) -> Option<DataValue>
Get value at offset from current row (for LAG/LEAD)
Sourcepub fn get_row_number(&self, row_index: usize) -> usize
pub fn get_row_number(&self, row_index: usize) -> usize
Get row number within partition (1-based)
Sourcepub fn get_frame_first_value(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_frame_first_value( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Get first value in frame
Sourcepub fn get_frame_last_value(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_frame_last_value( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Get last value in frame
Sourcepub fn get_first_value(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_first_value( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Get first value in partition
Sourcepub fn get_last_value(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_last_value( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Get last value in partition
Sourcepub fn partition_count(&self) -> usize
pub fn partition_count(&self) -> usize
Get the number of partitions
Sourcepub fn has_partitions(&self) -> bool
pub fn has_partitions(&self) -> bool
Check if context has partitions (vs single window)
Sourcepub fn is_running_aggregate_frame(&self) -> bool
pub fn is_running_aggregate_frame(&self) -> bool
Check if this is a running aggregate frame (UNBOUNDED PRECEDING to CURRENT ROW)
Sourcepub fn get_frame_rows(&self, row_index: usize) -> Vec<usize>
pub fn get_frame_rows(&self, row_index: usize) -> Vec<usize>
Get row indices within the window frame for a given row
Sourcepub fn get_frame_sum(&self, row_index: usize, column: &str) -> Option<DataValue>
pub fn get_frame_sum(&self, row_index: usize, column: &str) -> Option<DataValue>
Calculate sum of a column within the window frame for the given row
Sourcepub fn get_frame_count(
&self,
row_index: usize,
column: Option<&str>,
) -> Option<DataValue>
pub fn get_frame_count( &self, row_index: usize, column: Option<&str>, ) -> Option<DataValue>
Calculate count within the window frame
Sourcepub fn get_frame_avg(&self, row_index: usize, column: &str) -> Option<DataValue>
pub fn get_frame_avg(&self, row_index: usize, column: &str) -> Option<DataValue>
Calculate average of a column within the window frame
Sourcepub fn get_frame_stddev(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_frame_stddev( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate standard deviation within the window frame (sample stddev)
Sourcepub fn get_frame_variance(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_frame_variance( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate variance within the window frame (sample variance with n-1)
Sourcepub fn get_partition_sum(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_partition_sum( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate sum of a column over the partition containing the given row
Sourcepub fn get_partition_count(
&self,
row_index: usize,
column: Option<&str>,
) -> Option<DataValue>
pub fn get_partition_count( &self, row_index: usize, column: Option<&str>, ) -> Option<DataValue>
Calculate count of non-null values in a column over the partition
Sourcepub fn get_partition_avg(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_partition_avg( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate average of a column over the partition containing the given row
Sourcepub fn get_partition_min(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_partition_min( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate minimum value of a column over the partition containing the given row
Sourcepub fn get_partition_max(
&self,
row_index: usize,
column: &str,
) -> Option<DataValue>
pub fn get_partition_max( &self, row_index: usize, column: &str, ) -> Option<DataValue>
Calculate maximum value of a column over the partition containing the given row
Sourcepub fn get_partition_rows(&self, row_index: usize) -> Vec<usize>
pub fn get_partition_rows(&self, row_index: usize) -> Vec<usize>
Get all row indices in the partition containing the given row
Sourcepub fn get_frame_min(&self, row_index: usize, column: &str) -> Option<DataValue>
pub fn get_frame_min(&self, row_index: usize, column: &str) -> Option<DataValue>
Calculate minimum value within the frame for a given row
Sourcepub fn get_frame_max(&self, row_index: usize, column: &str) -> Option<DataValue>
pub fn get_frame_max(&self, row_index: usize, column: &str) -> Option<DataValue>
Calculate maximum value within the frame for a given row
Sourcepub fn evaluate_lag_batch(
&self,
visible_rows: &[usize],
column_name: &str,
offset: i64,
) -> Result<Vec<DataValue>>
pub fn evaluate_lag_batch( &self, visible_rows: &[usize], column_name: &str, offset: i64, ) -> Result<Vec<DataValue>>
Batch evaluate LAG function for multiple rows This is significantly faster than calling get_offset_value for each row
Sourcepub fn evaluate_lead_batch(
&self,
visible_rows: &[usize],
column_name: &str,
offset: i64,
) -> Result<Vec<DataValue>>
pub fn evaluate_lead_batch( &self, visible_rows: &[usize], column_name: &str, offset: i64, ) -> Result<Vec<DataValue>>
Batch evaluate LEAD function for multiple rows
Sourcepub fn evaluate_row_number_batch(
&self,
visible_rows: &[usize],
) -> Result<Vec<DataValue>>
pub fn evaluate_row_number_batch( &self, visible_rows: &[usize], ) -> Result<Vec<DataValue>>
Batch evaluate ROW_NUMBER function for multiple rows
Sourcepub fn get_rank(&self, row_index: usize) -> i64
pub fn get_rank(&self, row_index: usize) -> i64
Get rank of a row within its partition Ties get the same rank, and next rank(s) are skipped
Sourcepub fn get_dense_rank(&self, row_index: usize) -> i64
pub fn get_dense_rank(&self, row_index: usize) -> i64
Get dense rank of a row within its partition Ties get the same rank, but ranks are not skipped
Sourcepub fn evaluate_rank_batch(
&self,
visible_rows: &[usize],
) -> Result<Vec<DataValue>>
pub fn evaluate_rank_batch( &self, visible_rows: &[usize], ) -> Result<Vec<DataValue>>
Batch evaluate RANK function for multiple rows
Sourcepub fn evaluate_dense_rank_batch(
&self,
visible_rows: &[usize],
) -> Result<Vec<DataValue>>
pub fn evaluate_dense_rank_batch( &self, visible_rows: &[usize], ) -> Result<Vec<DataValue>>
Batch evaluate DENSE_RANK function for multiple rows
Sourcepub fn evaluate_sum_batch(
&self,
visible_rows: &[usize],
column_name: &str,
) -> Result<Vec<DataValue>>
pub fn evaluate_sum_batch( &self, visible_rows: &[usize], column_name: &str, ) -> Result<Vec<DataValue>>
Batch evaluate SUM window aggregate
Sourcepub fn evaluate_avg_batch(
&self,
visible_rows: &[usize],
column_name: &str,
) -> Result<Vec<DataValue>>
pub fn evaluate_avg_batch( &self, visible_rows: &[usize], column_name: &str, ) -> Result<Vec<DataValue>>
Batch evaluate AVG window aggregate
Sourcepub fn evaluate_min_batch(
&self,
visible_rows: &[usize],
column_name: &str,
) -> Result<Vec<DataValue>>
pub fn evaluate_min_batch( &self, visible_rows: &[usize], column_name: &str, ) -> Result<Vec<DataValue>>
Batch evaluate MIN window aggregate
Sourcepub fn evaluate_max_batch(
&self,
visible_rows: &[usize],
column_name: &str,
) -> Result<Vec<DataValue>>
pub fn evaluate_max_batch( &self, visible_rows: &[usize], column_name: &str, ) -> Result<Vec<DataValue>>
Batch evaluate MAX window aggregate
Sourcepub fn evaluate_count_batch(
&self,
visible_rows: &[usize],
column_name: Option<&str>,
) -> Result<Vec<DataValue>>
pub fn evaluate_count_batch( &self, visible_rows: &[usize], column_name: Option<&str>, ) -> Result<Vec<DataValue>>
Batch evaluate COUNT window aggregate
Auto Trait Implementations§
impl Freeze for WindowContext
impl !RefUnwindSafe for WindowContext
impl Send for WindowContext
impl Sync for WindowContext
impl Unpin for WindowContext
impl !UnwindSafe for WindowContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more