datafusion_physical_expr::aggregate

Struct AggregateFunctionExpr

Source
pub struct AggregateFunctionExpr { /* private fields */ }
Expand description

Physical aggregate expression of a UDAF.

Implementations§

Source§

impl AggregateFunctionExpr

Source

pub fn fun(&self) -> &AggregateUDF

Return the AggregateUDF used by this AggregateFunctionExpr

Source

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.

Source

pub fn name(&self) -> &str

Human readable name such as "MIN(c2)".

Source

pub fn is_distinct(&self) -> bool

Return if the aggregation is distinct

Source

pub fn ignore_nulls(&self) -> bool

Return if the aggregation ignores nulls

Source

pub fn is_reversed(&self) -> bool

Return if the aggregation is reversed

Source

pub fn is_nullable(&self) -> bool

Return if the aggregation is nullable

Source

pub fn field(&self) -> Field

the field of the final result of this aggregation.

Source

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

Source

pub fn state_fields(&self) -> Result<Vec<Field>>

the field of the final result of this aggregation.

Source

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

Source

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.

Source

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).

Source

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

Creates accumulator implementation that supports retract

Source

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.

Source

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.

Source

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).

Source

pub fn all_expressions(&self) -> AggregatePhysicalExpressions

Returns all expressions used in the AggregateFunctionExpr. These expressions are (1)function arguments, (2) order by expressions.

Source

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.

Source

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

Source

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

Source§

fn clone(&self) -> AggregateFunctionExpr

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AggregateFunctionExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AggregateFunctionExpr

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.