cryeo commented on issue #24335: [SPARK-27425] Add count_if functions URL: https://github.com/apache/spark/pull/24335#issuecomment-481731865 > we wouldn't add a new function unless it were standard SQL. Would you mind if I ask you the reason? [Presto](https://prestodb.github.io/docs/current/functions/aggregate.html#count_if) and [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#countif) provide this nevertheless it isn't ISO/ANSI standards. > With Spark SQL, it's pretty trivial to express count-if with a filter and count. As you said, we can archive this with existing functions like followings, which are a little bit inconvenient. - `COUNT(IF(very_complex_condition, 1, NULL))` - `COUNT(CASE WHEN very_complex_condition THEN 1 END)` - `SUM(IF(very_complex_condition, 1, NULL))` - `SUM(CASE WHEN very_complex_condition THEN 1 END)` However, I think that these are a little bit inconvenient and painful.
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
