Skip to content

Commit f36558e

Browse files
convert variance sample to UDF
Ref apache/datafusion#10667
1 parent 8a3a606 commit f36558e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/functions.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ pub fn covar(y: PyExpr, x: PyExpr) -> PyExpr {
5656
covar_samp(y, x)
5757
}
5858

59+
#[pyfunction]
60+
pub fn var_samp(expression: PyExpr) -> PyExpr {
61+
functions_aggregate::expr_fn::var_sample(expression.expr).into()
62+
}
63+
64+
#[pyfunction]
65+
/// Alias for [`var_samp`]
66+
pub fn var(y: PyExpr) -> PyExpr {
67+
var_samp(y)
68+
}
69+
5970
#[pyfunction]
6071
fn in_list(expr: PyExpr, value: Vec<PyExpr>, negated: bool) -> PyExpr {
6172
datafusion_expr::in_list(
@@ -593,9 +604,7 @@ aggregate_function!(sum, Sum);
593604
aggregate_function!(stddev, Stddev);
594605
aggregate_function!(stddev_pop, StddevPop);
595606
aggregate_function!(stddev_samp, Stddev);
596-
aggregate_function!(var, Variance);
597607
aggregate_function!(var_pop, VariancePop);
598-
aggregate_function!(var_samp, Variance);
599608
aggregate_function!(regr_avgx, RegrAvgx);
600609
aggregate_function!(regr_avgy, RegrAvgy);
601610
aggregate_function!(regr_count, RegrCount);

0 commit comments

Comments
 (0)