You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Philipp Spengler (Jira)" <ji...@apache.org> on 2024/03/28 13:56:00 UTC
[jira] [Commented] (SPARK-47397) count_distinct ignores null values
[ https://issues.apache.org/jira/browse/SPARK-47397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831809#comment-17831809 ]
Philipp Spengler commented on SPARK-47397:
------------------------------------------
This behavior is in line with the SQL standard. COUNT(column_name) is different from COUNT(*) (or COUNT(1)) in that in does not count null values. See the different output of
{code:java}
SELECT value, count(value) from test GROUP BY value
{code}
and
{code:java}
SELECT value, count(*) from test GROUP BY value
{code}
A nested distinct clause in COUNT does not change it's behavior - nulls will not be counted.
> count_distinct ignores null values
> ----------------------------------
>
> Key: SPARK-47397
> URL: https://issues.apache.org/jira/browse/SPARK-47397
> Project: Spark
> Issue Type: Bug
> Components: Documentation, Spark Core
> Affects Versions: 3.4.1
> Reporter: Martin Rueckl
> Priority: Critical
> Attachments: image-2024-03-14-16-12-35-267.png, image-2024-03-14-16-13-03-107.png
>
>
> The documentation states, that in group by and count statements, null values will not be ignored / form their own groups.
> !image-2024-03-14-16-13-03-107.png|width=491,height=373!
> However, the behavior of count_distinct does not account for nulls.
> Either the documentation or the implementation is wrong here...
> !image-2024-03-14-16-12-35-267.png!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org