Skip to content

Commit 62f3d2c

Browse files
committed
Set corr to use macro for pyfunction
1 parent 4f93736 commit 62f3d2c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/functions.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ pub fn approx_percentile_cont_with_weight(
8787
add_builder_fns_to_aggregate(agg_fn, None, filter, None, None)
8888
}
8989

90-
#[pyfunction]
91-
pub fn corr(y: PyExpr, x: PyExpr, distinct: bool) -> PyResult<PyExpr> {
92-
let expr = functions_aggregate::expr_fn::corr(y.expr, x.expr);
93-
if distinct {
94-
Ok(expr.distinct().build()?.into())
95-
} else {
96-
Ok(expr.into())
97-
}
98-
}
99-
10090
#[pyfunction]
10191
pub fn grouping(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
10292
let expr = functions_aggregate::expr_fn::grouping(expression.expr);
@@ -590,12 +580,9 @@ fn window(
590580
// are appropriate.
591581
macro_rules! aggregate_function {
592582
($NAME: ident) => {
593-
aggregate_function!($NAME, functions_aggregate::expr_fn::$NAME, expr);
594-
};
595-
($NAME: ident, $FUNC: path) => {
596-
aggregate_function!($NAME, $FUNC, expr);
583+
aggregate_function!($NAME, expr);
597584
};
598-
($NAME: ident, $FUNC: path, $($arg:ident)*) => {
585+
($NAME: ident, $($arg:ident)*) => {
599586
#[pyfunction]
600587
fn $NAME(
601588
$($arg: PyExpr),*,
@@ -604,7 +591,7 @@ macro_rules! aggregate_function {
604591
order_by: Option<Vec<PyExpr>>,
605592
null_treatment: Option<NullTreatment>
606593
) -> PyResult<PyExpr> {
607-
let agg_fn = $FUNC($($arg.into()),*);
594+
let agg_fn = functions_aggregate::expr_fn::$NAME($($arg.into()),*);
608595

609596
add_builder_fns_to_aggregate(agg_fn, distinct, filter, order_by, null_treatment)
610597
}
@@ -843,6 +830,7 @@ aggregate_function!(bit_or);
843830
aggregate_function!(bit_xor);
844831
aggregate_function!(bool_and);
845832
aggregate_function!(bool_or);
833+
aggregate_function!(corr, y x);
846834

847835
fn add_builder_fns_to_window(
848836
window_fn: Expr,

0 commit comments

Comments
 (0)