Skip to content

Commit 70069d7

Browse files
migrage corr to UDAF
Ref: apache/datafusion#10884
1 parent 2cd6853 commit 70069d7

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
@@ -98,6 +98,16 @@ pub fn avg(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
9898
}
9999
}
100100

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

791801
aggregate_function!(array_agg, ArrayAgg);
792-
aggregate_function!(corr, Correlation);
793802
aggregate_function!(grouping, Grouping);
794803
aggregate_function!(max, Max);
795804
aggregate_function!(mean, Avg);

0 commit comments

Comments
 (0)