Skip to content

Commit fdee791

Browse files
committed
Use macro for bool_and and bool_or
1 parent 176092c commit fdee791

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

src/functions.rs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +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 bool_and(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
92-
let expr = functions_aggregate::expr_fn::bool_and(expression.expr);
93-
if distinct {
94-
Ok(expr.distinct().build()?.into())
95-
} else {
96-
Ok(expr.into())
97-
}
98-
}
99-
100-
#[pyfunction]
101-
pub fn bool_or(expression: PyExpr, distinct: bool) -> PyResult<PyExpr> {
102-
let expr = functions_aggregate::expr_fn::bool_or(expression.expr);
103-
if distinct {
104-
Ok(expr.distinct().build()?.into())
105-
} else {
106-
Ok(expr.into())
107-
}
108-
}
109-
11090
#[pyfunction]
11191
pub fn corr(y: PyExpr, x: PyExpr, distinct: bool) -> PyResult<PyExpr> {
11292
let expr = functions_aggregate::expr_fn::corr(y.expr, x.expr);
@@ -609,6 +589,9 @@ fn window(
609589
// function and we rely on the wrappers to only use those that
610590
// are appropriate.
611591
macro_rules! aggregate_function {
592+
($NAME: ident) => {
593+
aggregate_function!($NAME, functions_aggregate::expr_fn::$NAME, expr);
594+
};
612595
($NAME: ident, $FUNC: path) => {
613596
aggregate_function!($NAME, $FUNC, expr);
614597
};
@@ -851,13 +834,15 @@ array_fn!(array_resize, array size value);
851834
array_fn!(flatten, array);
852835
array_fn!(range, start stop step);
853836

854-
aggregate_function!(array_agg, functions_aggregate::array_agg::array_agg);
855-
aggregate_function!(max, functions_aggregate::min_max::max);
856-
aggregate_function!(min, functions_aggregate::min_max::min);
857-
aggregate_function!(avg, functions_aggregate::expr_fn::avg);
858-
aggregate_function!(bit_and, functions_aggregate::expr_fn::bit_and);
859-
aggregate_function!(bit_or, functions_aggregate::expr_fn::bit_or);
860-
aggregate_function!(bit_xor, functions_aggregate::expr_fn::bit_xor);
837+
aggregate_function!(array_agg);
838+
aggregate_function!(max);
839+
aggregate_function!(min);
840+
aggregate_function!(avg);
841+
aggregate_function!(bit_and);
842+
aggregate_function!(bit_or);
843+
aggregate_function!(bit_xor);
844+
aggregate_function!(bool_and);
845+
aggregate_function!(bool_or);
861846

862847
fn add_builder_fns_to_window(
863848
window_fn: Expr,

0 commit comments

Comments
 (0)