From 7791cac1e0810831e26cc3562ae050bd2c4070e1 Mon Sep 17 00:00:00 2001 From: Michael-J-Ward Date: Wed, 24 Jul 2024 17:47:12 -0500 Subject: [PATCH] re-implement count_star --- src/functions.rs | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 56e26500..a4658dba 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -583,23 +583,13 @@ fn col(name: &str) -> PyResult { }) } -// TODO: do we want to create an equivalent? -// /// Create a COUNT(1) aggregate expression -// #[pyfunction] -// fn count_star() -> PyResult { -// Ok(PyExpr { -// expr: Expr::AggregateFunction(AggregateFunction { -// func_def: datafusion_expr::expr::AggregateFunctionDefinition::BuiltIn( -// aggregate_function::AggregateFunction::Count, -// ), -// args: vec![lit(1)], -// distinct: false, -// filter: None, -// order_by: None, -// null_treatment: None, -// }), -// }) -// } +// TODO: should we just expose this in python? +/// Create a COUNT(1) aggregate expression +#[pyfunction] +fn count_star() -> PyExpr { + functions_aggregate::expr_fn::count(lit(1)).into() + +} /// Wrapper for [`functions_aggregate::expr_fn::count`] /// Count the number of non-null values in the column @@ -1030,7 +1020,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(cosh))?; m.add_wrapped(wrap_pyfunction!(cot))?; m.add_wrapped(wrap_pyfunction!(count))?; - // m.add_wrapped(wrap_pyfunction!(count_star))?; + m.add_wrapped(wrap_pyfunction!(count_star))?; m.add_wrapped(wrap_pyfunction!(covar))?; m.add_wrapped(wrap_pyfunction!(covar_pop))?; m.add_wrapped(wrap_pyfunction!(covar_samp))?;