Skip to content

Apache DataFusion SQL Query Engine

Docs: Explain the usage of logical expressions for `create_aggregate_expr` (#11458)

Jay Zhand01301d2ee9e
diff --git a/datafusion/physical-expr-common/src/aggregate/mod.rs b/datafusion/physical-expr-common/src/aggregate/mod.rs
index 35666f199a..db4581a622 100644
--- a/datafusion/physical-expr-common/src/aggregate/mod.rs
+++ b/datafusion/physical-expr-common/src/aggregate/mod.rs
@@ -43,6 +43,14 @@ use datafusion_expr::utils::AggregateOrderSensitivity;
/// 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 `&[]`.
#[allow(clippy::too_many_arguments)]
pub fn create_aggregate_expr(
fun: &AggregateUDF,