diff --git a/src/functions.rs b/src/functions.rs index 7bab918b5..345045b8a 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -87,6 +87,16 @@ pub fn approx_percentile_cont_with_weight( } } +#[pyfunction] +pub fn avg(expression: PyExpr, distinct: bool) -> PyResult { + let expr = functions_aggregate::expr_fn::avg(expression.expr); + if distinct { + Ok(expr.distinct().build()?.into()) + } else { + Ok(expr.into()) + } +} + #[pyfunction] pub fn sum(args: PyExpr) -> PyExpr { functions_aggregate::expr_fn::sum(args.expr).into() @@ -749,7 +759,6 @@ array_fn!(flatten, array); array_fn!(range, start stop step); aggregate_function!(array_agg, ArrayAgg); -aggregate_function!(avg, Avg); aggregate_function!(corr, Correlation); aggregate_function!(grouping, Grouping); aggregate_function!(max, Max);