Struct datafusion::logical_expr::AggregateUDF
source · pub struct AggregateUDF {
pub name: String,
pub signature: Signature,
pub return_type: Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Send + Sync>,
pub accumulator: Arc<dyn Fn(&DataType) -> Result<Box<dyn Accumulator, Global>, DataFusionError> + Send + Sync>,
pub state_type: Arc<dyn Fn(&DataType) -> Result<Arc<Vec<DataType, Global>>, DataFusionError> + Send + Sync>,
}
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.
Fields§
§name: String
name
signature: Signature
Signature (input arguments)
return_type: Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Send + Sync>
Return type
accumulator: Arc<dyn Fn(&DataType) -> Result<Box<dyn Accumulator, Global>, DataFusionError> + Send + Sync>
actual implementation
state_type: Arc<dyn Fn(&DataType) -> Result<Arc<Vec<DataType, Global>>, DataFusionError> + Send + Sync>
the accumulator’s state’s description as a function of the return type
Implementations§
source§impl AggregateUDF
impl AggregateUDF
sourcepub fn new(
name: &str,
signature: &Signature,
return_type: &Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Send + Sync>,
accumulator: &Arc<dyn Fn(&DataType) -> Result<Box<dyn Accumulator, Global>, DataFusionError> + Send + Sync>,
state_type: &Arc<dyn Fn(&DataType) -> Result<Arc<Vec<DataType, Global>>, DataFusionError> + Send + Sync>
) -> AggregateUDF
pub fn new( name: &str, signature: &Signature, return_type: &Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Send + Sync>, accumulator: &Arc<dyn Fn(&DataType) -> Result<Box<dyn Accumulator, Global>, DataFusionError> + Send + Sync>, state_type: &Arc<dyn Fn(&DataType) -> Result<Arc<Vec<DataType, Global>>, DataFusionError> + Send + Sync> ) -> AggregateUDF
Create a new AggregateUDF
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<AggregateUDF> for AggregateUDF
impl PartialEq<AggregateUDF> for AggregateUDF
source§fn eq(&self, other: &AggregateUDF) -> bool
fn eq(&self, other: &AggregateUDF) -> bool
self
and other
values to be equal, and is used
by ==
.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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.