Skip to content

Commit c08a35d

Browse files
migrate stddev to UDAF
Ref: apache/datafusion#10827
1 parent 136a3c3 commit c08a35d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/functions.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,26 @@ pub fn covar(y: PyExpr, x: PyExpr) -> PyExpr {
149149
covar_samp(y, x)
150150
}
151151

152+
#[pyfunction]
153+
pub fn stddev(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
154+
let expr = functions_aggregate::expr_fn::stddev(expression.expr);
155+
if distinct {
156+
Ok(expr.distinct().build()?.into())
157+
} else {
158+
Ok(expr.into())
159+
}
160+
}
161+
162+
#[pyfunction]
163+
pub fn stddev_pop(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
164+
let expr = functions_aggregate::expr_fn::stddev_pop(expression.expr);
165+
if distinct {
166+
Ok(expr.distinct().build()?.into())
167+
} else {
168+
Ok(expr.into())
169+
}
170+
}
171+
152172
#[pyfunction]
153173
pub fn var_samp(expression: PyExpr) -> PyExpr {
154174
functions_aggregate::expr_fn::var_sample(expression.expr).into()
@@ -787,8 +807,6 @@ array_fn!(range, start stop step);
787807
aggregate_function!(array_agg, ArrayAgg);
788808
aggregate_function!(max, Max);
789809
aggregate_function!(min, Min);
790-
aggregate_function!(stddev, Stddev);
791-
aggregate_function!(stddev_pop, StddevPop);
792810
aggregate_function!(stddev_samp, Stddev);
793811
aggregate_function!(var_pop, VariancePop);
794812
aggregate_function!(regr_avgx, RegrAvgx);

0 commit comments

Comments
 (0)