@@ -31,7 +31,6 @@ use datafusion::functions_aggregate;
3131use datafusion_common:: { Column , ScalarValue , TableReference } ;
3232use datafusion_expr:: expr:: Alias ;
3333use datafusion_expr:: {
34- aggregate_function,
3534 expr:: {
3635 find_df_window_func, AggregateFunction , AggregateFunctionDefinition , Sort , WindowFunction ,
3736 } ,
@@ -327,21 +326,29 @@ fn col(name: &str) -> PyResult<PyExpr> {
327326 } )
328327}
329328
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
331349#[ 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 ( )
345352}
346353
347354/// Create a CASE WHEN statement with literal WHEN expressions for comparison to the base expression.
@@ -730,7 +737,6 @@ aggregate_function!(
730737aggregate_function ! ( array_agg, ArrayAgg ) ;
731738aggregate_function ! ( avg, Avg ) ;
732739aggregate_function ! ( corr, Correlation ) ;
733- aggregate_function ! ( count, Count ) ;
734740aggregate_function ! ( grouping, Grouping ) ;
735741aggregate_function ! ( max, Max ) ;
736742aggregate_function ! ( mean, Avg ) ;
@@ -791,7 +797,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
791797 m. add_wrapped ( wrap_pyfunction ! ( cosh) ) ?;
792798 m. add_wrapped ( wrap_pyfunction ! ( cot) ) ?;
793799 m. add_wrapped ( wrap_pyfunction ! ( count) ) ?;
794- m. add_wrapped ( wrap_pyfunction ! ( count_star) ) ?;
800+ // m.add_wrapped(wrap_pyfunction!(count_star))?;
795801 m. add_wrapped ( wrap_pyfunction ! ( covar) ) ?;
796802 m. add_wrapped ( wrap_pyfunction ! ( covar_pop) ) ?;
797803 m. add_wrapped ( wrap_pyfunction ! ( covar_samp) ) ?;
0 commit comments