Skip to content

Commit

Permalink
migrate stddev 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 136a3c3 commit c08a35d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ pub fn covar(y: PyExpr, x: PyExpr) -> PyExpr {
covar_samp(y, x)
}

#[pyfunction]
pub fn stddev(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
let expr = functions_aggregate::expr_fn::stddev(expression.expr);
if distinct {
Ok(expr.distinct().build()?.into())
} else {
Ok(expr.into())
}
}

#[pyfunction]
pub fn stddev_pop(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
let expr = functions_aggregate::expr_fn::stddev_pop(expression.expr);
if distinct {
Ok(expr.distinct().build()?.into())
} else {
Ok(expr.into())
}
}

#[pyfunction]
pub fn var_samp(expression: PyExpr) -> PyExpr {
functions_aggregate::expr_fn::var_sample(expression.expr).into()
Expand Down Expand Up @@ -787,8 +807,6 @@ array_fn!(range, start stop step);
aggregate_function!(array_agg, ArrayAgg);
aggregate_function!(max, Max);
aggregate_function!(min, Min);
aggregate_function!(stddev, Stddev);
aggregate_function!(stddev_pop, StddevPop);
aggregate_function!(stddev_samp, Stddev);
aggregate_function!(var_pop, VariancePop);
aggregate_function!(regr_avgx, RegrAvgx);
Expand Down

0 comments on commit c08a35d

Please sign in to comment.