Skip to content

Commit d0018ea

Browse files
migrate stddev to UDAF
Ref: apache/datafusion#10827
1 parent c790454 commit d0018ea

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/functions.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ pub fn covar(y: PyExpr, x: PyExpr) -> PyExpr {
150150
covar_samp(y, x)
151151
}
152152

153+
#[pyfunction]
154+
pub fn stddev(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
155+
let expr = functions_aggregate::expr_fn::stddev(expression.expr);
156+
if distinct {
157+
Ok(expr.distinct().build()?.into())
158+
} else {
159+
Ok(expr.into())
160+
}
161+
}
162+
163+
#[pyfunction]
164+
pub fn stddev_pop(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
165+
let expr = functions_aggregate::expr_fn::stddev_pop(expression.expr);
166+
if distinct {
167+
Ok(expr.distinct().build()?.into())
168+
} else {
169+
Ok(expr.into())
170+
}
171+
}
172+
153173
#[pyfunction]
154174
pub fn var_samp(expression: PyExpr) -> PyExpr {
155175
functions_aggregate::expr_fn::var_sample(expression.expr).into()
@@ -817,8 +837,6 @@ array_fn!(range, start stop step);
817837
aggregate_function!(array_agg, ArrayAgg);
818838
aggregate_function!(max, Max);
819839
aggregate_function!(min, Min);
820-
aggregate_function!(stddev, Stddev);
821-
aggregate_function!(stddev_pop, StddevPop);
822840
aggregate_function!(stddev_samp, Stddev);
823841
aggregate_function!(var_pop, VariancePop);
824842
aggregate_function!(regr_avgx, RegrAvgx);

0 commit comments

Comments
 (0)