Skip to content

Commit da69cee

Browse files
migrage corr to UDAF
Ref: apache/datafusion#10884
1 parent 6509d6d commit da69cee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/functions.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ pub fn avg(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
9797
}
9898
}
9999

100+
#[pyfunction]
101+
pub fn corr(y: PyExpr, x: PyExpr, distinct: bool) -> PyResult<PyExpr> {
102+
let expr = functions_aggregate::expr_fn::corr(y.expr, x.expr);
103+
if distinct {
104+
Ok(expr.distinct().build()?.into())
105+
} else {
106+
Ok(expr.into())
107+
}
108+
}
109+
100110
#[pyfunction]
101111
pub fn sum(args: PyExpr) -> PyExpr {
102112
functions_aggregate::expr_fn::sum(args.expr).into()
@@ -759,7 +769,6 @@ array_fn!(flatten, array);
759769
array_fn!(range, start stop step);
760770

761771
aggregate_function!(array_agg, ArrayAgg);
762-
aggregate_function!(corr, Correlation);
763772
aggregate_function!(grouping, Grouping);
764773
aggregate_function!(max, Max);
765774
aggregate_function!(mean, Avg);

0 commit comments

Comments
 (0)