Function datafusion_physical_plan::udaf::create_aggregate_expr
source · pub fn create_aggregate_expr(
fun: &AggregateUDF,
input_phy_exprs: &[Arc<dyn PhysicalExpr>],
input_exprs: &[Expr],
sort_exprs: &[Expr],
ordering_req: &[PhysicalSortExpr],
schema: &Schema,
name: Option<String>,
ignore_nulls: bool,
is_distinct: bool,
) -> Result<Arc<dyn AggregateExpr>, DataFusionError>
Expand description
Creates a physical expression of the UDAF, that includes all necessary type coercion.
This function errors when args
’ can’t be coerced to a valid argument type of the UDAF.
input_exprs
and sort_exprs
are used for customizing Accumulator
whose behavior depends on arguments such as the ORDER BY
.
For example to call ARRAY_AGG(x ORDER BY y)
would pass y
to sort_exprs
, x
to input_exprs
input_exprs
and sort_exprs
are used for customizing Accumulator as the arguments in AccumulatorArgs
,
if you don’t need them it is fine to pass empty slice &[]
.
is_reversed
is used to indicate whether the aggregation is running in reverse order,
it could be used to hint Accumulator to accumulate in the reversed order,
you can just set to false if you are not reversing expression
You can also create expression by AggregateExprBuilder