Skip to content

Commit

Permalink
convert variance sample to UDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-J-Ward committed Jun 12, 2024
1 parent 8a3a606 commit f36558e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ pub fn covar(y: PyExpr, x: PyExpr) -> PyExpr {
covar_samp(y, x)
}

#[pyfunction]
pub fn var_samp(expression: PyExpr) -> PyExpr {
functions_aggregate::expr_fn::var_sample(expression.expr).into()
}

#[pyfunction]
/// Alias for [`var_samp`]
pub fn var(y: PyExpr) -> PyExpr {
var_samp(y)
}

#[pyfunction]
fn in_list(expr: PyExpr, value: Vec<PyExpr>, negated: bool) -> PyExpr {
datafusion_expr::in_list(
Expand Down Expand Up @@ -593,9 +604,7 @@ aggregate_function!(sum, Sum);
aggregate_function!(stddev, Stddev);
aggregate_function!(stddev_pop, StddevPop);
aggregate_function!(stddev_samp, Stddev);
aggregate_function!(var, Variance);
aggregate_function!(var_pop, VariancePop);
aggregate_function!(var_samp, Variance);
aggregate_function!(regr_avgx, RegrAvgx);
aggregate_function!(regr_avgy, RegrAvgy);
aggregate_function!(regr_count, RegrCount);
Expand Down

0 comments on commit f36558e

Please sign in to comment.