Weijun-H commented on issue #10231: URL: https://github.com/apache/datafusion/issues/10231#issuecomment-2077598083
The previous implementation appears to be incorrect because the variable 'count' will count all 'Expr' rather than just the null ones. https://github.com/apache/datafusion/blob/b87f210dbdd90e5f65caefac1eeb053b0f0f612e/datafusion/core/src/dataframe/mod.rs#L532-L539 https://github.com/apache/datafusion/blob/b87f210dbdd90e5f65caefac1eeb053b0f0f612e/datafusion/expr/src/expr_fn.rs#L206-L216 Create a new aggregate function using filter could fix this issue ``` rust /// Create an expression to represent the count_null() aggregate function pub fn count_null(expr: Expr) -> Expr { Expr::AggregateFunction(AggregateFunction::new( aggregate_function::AggregateFunction::Count, vec![expr.clone()], false, Some(Box::new(expr.is_null())), None, None, )) } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
