pub struct AggregateFunctionExpr { /* private fields */ }
Expand description
Physical aggregate expression of a UDAF.
Implementations§
Source§impl AggregateFunctionExpr
impl AggregateFunctionExpr
Sourcepub fn fun(&self) -> &AggregateUDF
pub fn fun(&self) -> &AggregateUDF
Return the AggregateUDF
used by this AggregateFunctionExpr
Sourcepub fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>>
pub fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>>
expressions that are passed to the Accumulator.
Single-column aggregations such as sum
return a single value, others (e.g. cov
) return many.
Sourcepub fn is_distinct(&self) -> bool
pub fn is_distinct(&self) -> bool
Return if the aggregation is distinct
Sourcepub fn ignore_nulls(&self) -> bool
pub fn ignore_nulls(&self) -> bool
Return if the aggregation ignores nulls
Sourcepub fn is_reversed(&self) -> bool
pub fn is_reversed(&self) -> bool
Return if the aggregation is reversed
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Return if the aggregation is nullable
Sourcepub fn create_accumulator(&self) -> Result<Box<dyn Accumulator>>
pub fn create_accumulator(&self) -> Result<Box<dyn Accumulator>>
the accumulator used to accumulate values from the expressions.
the accumulator expects the same number of arguments as expressions
and must
return states with the same description as state_fields
Sourcepub fn state_fields(&self) -> Result<Vec<Field>>
pub fn state_fields(&self) -> Result<Vec<Field>>
the field of the final result of this aggregation.
Sourcepub fn order_bys(&self) -> Option<LexOrderingRef<'_>>
pub fn order_bys(&self) -> Option<LexOrderingRef<'_>>
Order by requirements for the aggregate function
By default it is None
(there is no requirement)
Order-sensitive aggregators, such as FIRST_VALUE(x ORDER BY y)
should implement this
Sourcepub fn order_sensitivity(&self) -> AggregateOrderSensitivity
pub fn order_sensitivity(&self) -> AggregateOrderSensitivity
Indicates whether aggregator can produce the correct result with any arbitrary input ordering. By default, we assume that aggregate expressions are order insensitive.
Sourcepub fn with_beneficial_ordering(
self: Arc<Self>,
beneficial_ordering: bool,
) -> Result<Option<AggregateFunctionExpr>>
pub fn with_beneficial_ordering( self: Arc<Self>, beneficial_ordering: bool, ) -> Result<Option<AggregateFunctionExpr>>
Sets the indicator whether ordering requirements of the aggregator is
satisfied by its input. If this is not the case, aggregators with order
sensitivity AggregateOrderSensitivity::Beneficial
can still produce
the correct result with possibly more work internally.
§Returns
Returns Ok(Some(updated_expr))
if the process completes successfully.
If the expression can benefit from existing input ordering, but does
not implement the method, returns an error. Order insensitive and hard
requirement aggregators return Ok(None)
.
Sourcepub fn create_sliding_accumulator(&self) -> Result<Box<dyn Accumulator>>
pub fn create_sliding_accumulator(&self) -> Result<Box<dyn Accumulator>>
Creates accumulator implementation that supports retract
Sourcepub fn groups_accumulator_supported(&self) -> bool
pub fn groups_accumulator_supported(&self) -> bool
If the aggregate expression has a specialized
GroupsAccumulator
implementation. If this returns true,
[Self::create_groups_accumulator
] will be called.
Sourcepub fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>>
pub fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>>
Return a specialized GroupsAccumulator
that manages state
for all groups.
For maximum performance, a GroupsAccumulator
should be
implemented in addition to Accumulator
.
Sourcepub fn reverse_expr(&self) -> Option<AggregateFunctionExpr>
pub fn reverse_expr(&self) -> Option<AggregateFunctionExpr>
Construct an expression that calculates the aggregate in reverse. Typically the “reverse” expression is itself (e.g. SUM, COUNT). For aggregates that do not support calculation in reverse, returns None (which is the default value).
Sourcepub fn all_expressions(&self) -> AggregatePhysicalExpressions
pub fn all_expressions(&self) -> AggregatePhysicalExpressions
Returns all expressions used in the AggregateFunctionExpr
.
These expressions are (1)function arguments, (2) order by expressions.
Sourcepub fn with_new_expressions(
&self,
_args: Vec<Arc<dyn PhysicalExpr>>,
_order_by_exprs: Vec<Arc<dyn PhysicalExpr>>,
) -> Option<AggregateFunctionExpr>
pub fn with_new_expressions( &self, _args: Vec<Arc<dyn PhysicalExpr>>, _order_by_exprs: Vec<Arc<dyn PhysicalExpr>>, ) -> Option<AggregateFunctionExpr>
Rewrites AggregateFunctionExpr
, with new expressions given. The argument should be consistent
with the return value of the AggregateFunctionExpr::all_expressions
method.
Returns Some(Arc<dyn AggregateExpr>)
if re-write is supported, otherwise returns None
.
Sourcepub fn get_minmax_desc(&self) -> Option<(Field, bool)>
pub fn get_minmax_desc(&self) -> Option<(Field, bool)>
If this function is max, return (output_field, true) if the function is min, return (output_field, false) otherwise return None (the default)
output_field is the name of the column produced by this aggregate
Note: this is used to use special aggregate implementations in certain conditions
Sourcepub fn default_value(&self, data_type: &DataType) -> Result<ScalarValue>
pub fn default_value(&self, data_type: &DataType) -> Result<ScalarValue>
Returns default value of the function given the input is Null
Most of the aggregate function return Null if input is Null,
while count
returns 0 if input is Null
Trait Implementations§
Source§impl Clone for AggregateFunctionExpr
impl Clone for AggregateFunctionExpr
Source§fn clone(&self) -> AggregateFunctionExpr
fn clone(&self) -> AggregateFunctionExpr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AggregateFunctionExpr
impl Debug for AggregateFunctionExpr
Source§impl PartialEq for AggregateFunctionExpr
impl PartialEq for AggregateFunctionExpr
Auto Trait Implementations§
impl Freeze for AggregateFunctionExpr
impl !RefUnwindSafe for AggregateFunctionExpr
impl Send for AggregateFunctionExpr
impl Sync for AggregateFunctionExpr
impl Unpin for AggregateFunctionExpr
impl !UnwindSafe for AggregateFunctionExpr
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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