@@ -31,7 +31,6 @@ use datafusion::functions_aggregate;
31
31
use datafusion_common:: { Column , ScalarValue , TableReference } ;
32
32
use datafusion_expr:: expr:: Alias ;
33
33
use datafusion_expr:: {
34
- aggregate_function,
35
34
expr:: {
36
35
find_df_window_func, AggregateFunction , AggregateFunctionDefinition , Sort , WindowFunction ,
37
36
} ,
@@ -327,21 +326,29 @@ fn col(name: &str) -> PyResult<PyExpr> {
327
326
} )
328
327
}
329
328
330
- /// Create a COUNT(1) aggregate expression
329
+ // TODO: do we want to create an equivalent?
330
+ // /// Create a COUNT(1) aggregate expression
331
+ // #[pyfunction]
332
+ // fn count_star() -> PyResult<PyExpr> {
333
+ // Ok(PyExpr {
334
+ // expr: Expr::AggregateFunction(AggregateFunction {
335
+ // func_def: datafusion_expr::expr::AggregateFunctionDefinition::BuiltIn(
336
+ // aggregate_function::AggregateFunction::Count,
337
+ // ),
338
+ // args: vec![lit(1)],
339
+ // distinct: false,
340
+ // filter: None,
341
+ // order_by: None,
342
+ // null_treatment: None,
343
+ // }),
344
+ // })
345
+ // }
346
+
347
+ /// Wrapper for [`functions_aggregate::expr_fn::count`]
348
+ /// Count the number of non-null values in the column
331
349
#[ pyfunction]
332
- fn count_star ( ) -> PyResult < PyExpr > {
333
- Ok ( PyExpr {
334
- expr : Expr :: AggregateFunction ( AggregateFunction {
335
- func_def : datafusion_expr:: expr:: AggregateFunctionDefinition :: BuiltIn (
336
- aggregate_function:: AggregateFunction :: Count ,
337
- ) ,
338
- args : vec ! [ lit( 1 ) ] ,
339
- distinct : false ,
340
- filter : None ,
341
- order_by : None ,
342
- null_treatment : None ,
343
- } ) ,
344
- } )
350
+ fn count ( expr : PyExpr ) -> PyExpr {
351
+ functions_aggregate:: expr_fn:: count ( expr. expr ) . into ( )
345
352
}
346
353
347
354
/// Create a CASE WHEN statement with literal WHEN expressions for comparison to the base expression.
@@ -730,7 +737,6 @@ aggregate_function!(
730
737
aggregate_function ! ( array_agg, ArrayAgg ) ;
731
738
aggregate_function ! ( avg, Avg ) ;
732
739
aggregate_function ! ( corr, Correlation ) ;
733
- aggregate_function ! ( count, Count ) ;
734
740
aggregate_function ! ( grouping, Grouping ) ;
735
741
aggregate_function ! ( max, Max ) ;
736
742
aggregate_function ! ( mean, Avg ) ;
@@ -791,7 +797,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
791
797
m. add_wrapped ( wrap_pyfunction ! ( cosh) ) ?;
792
798
m. add_wrapped ( wrap_pyfunction ! ( cot) ) ?;
793
799
m. add_wrapped ( wrap_pyfunction ! ( count) ) ?;
794
- m. add_wrapped ( wrap_pyfunction ! ( count_star) ) ?;
800
+ // m.add_wrapped(wrap_pyfunction!(count_star))?;
795
801
m. add_wrapped ( wrap_pyfunction ! ( covar) ) ?;
796
802
m. add_wrapped ( wrap_pyfunction ! ( covar_pop) ) ?;
797
803
m. add_wrapped ( wrap_pyfunction ! ( covar_samp) ) ?;
0 commit comments