Skip to content

Commit

Permalink
migrate avg to UDAF
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-J-Ward committed Jul 24, 2024
1 parent 1400069 commit 6509d6d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ pub fn approx_percentile_cont_with_weight(
}
}

#[pyfunction]
pub fn avg(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
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()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6509d6d

Please sign in to comment.