Struct datafusion_expr::AggregateUDF
source · pub struct AggregateUDF { /* private fields */ }
Expand description
Logical representation of a user-defined aggregate function (UDAF).
An aggregate function combines the values from multiple input rows
into a single output “aggregate” (summary) row. It is different
from a scalar function because it is stateful across batches. User
defined aggregate functions can be used as normal SQL aggregate
functions (GROUP BY
clause) as well as window functions (OVER
clause).
AggregateUDF
provides DataFusion the information needed to plan
and call aggregate functions, including name, type information,
and a factory function to create Accumulator
, which peform the
actual aggregation.
For more information, please see the examples.
Implementations§
source§impl AggregateUDF
impl AggregateUDF
sourcepub fn new(
name: &str,
signature: &Signature,
return_type: &ReturnTypeFunction,
accumulator: &AccumulatorFactoryFunction,
state_type: &StateTypeFunction
) -> Self
pub fn new( name: &str, signature: &Signature, return_type: &ReturnTypeFunction, accumulator: &AccumulatorFactoryFunction, state_type: &StateTypeFunction ) -> Self
Create a new AggregateUDF
sourcepub fn call(&self, args: Vec<Expr>) -> Expr
pub fn call(&self, args: Vec<Expr>) -> Expr
creates an Expr
that calls the aggregate function.
This utility allows using the UDAF without requiring access to the registry, such as with the DataFrame API.
sourcepub fn signature(&self) -> &Signature
pub fn signature(&self) -> &Signature
Returns this function’s signature (what input types are accepted)
sourcepub fn return_type(&self, args: &[DataType]) -> Result<DataType>
pub fn return_type(&self, args: &[DataType]) -> Result<DataType>
Return the type of the function given its input types
sourcepub fn accumulator(
&self,
return_type: &DataType
) -> Result<Box<dyn Accumulator>>
pub fn accumulator( &self, return_type: &DataType ) -> Result<Box<dyn Accumulator>>
Return an accumualator the given aggregate, given its return datatype.
sourcepub fn state_type(&self, return_type: &DataType) -> Result<Vec<DataType>>
pub fn state_type(&self, return_type: &DataType) -> Result<Vec<DataType>>
Return the type of the intermediate state used by this aggregator, given its return datatype. Supports multi-phase aggregations
Trait Implementations§
source§impl Clone for AggregateUDF
impl Clone for AggregateUDF
source§fn clone(&self) -> AggregateUDF
fn clone(&self) -> AggregateUDF
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AggregateUDF
impl Debug for AggregateUDF
source§impl Hash for AggregateUDF
impl Hash for AggregateUDF
source§impl PartialEq for AggregateUDF
impl PartialEq for AggregateUDF
impl Eq for AggregateUDF
Auto Trait Implementations§
impl !RefUnwindSafe for AggregateUDF
impl Send for AggregateUDF
impl Sync for AggregateUDF
impl Unpin for AggregateUDF
impl !UnwindSafe for AggregateUDF
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.