You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Milan Dankovic (Jira)" <ji...@apache.org> on 2026/06/26 13:00:00 UTC

[jira] [Created] (SPARK-57715) PIVOT count() incorrectly returns null for missing pivot categories

Milan Dankovic created SPARK-57715:
--------------------------------------

             Summary: PIVOT count() incorrectly returns null for missing pivot categories
                 Key: SPARK-57715
                 URL: https://issues.apache.org/jira/browse/SPARK-57715
             Project: Spark
          Issue Type: Bug
          Components: Spark Core
    Affects Versions: 4.2.0
            Reporter: Milan Dankovic


When PIVOT has no matching rows for a pivot category, count() incorrectly returns NULL. Other systems such as DuckDB and SQL Server return 0 instead. Note: this was found internally.

 
{code:java}
SELECT * FROM (
  VALUES (1, 'a', 10), (1, 'a', 20), (1, 'b', 30), (2, 'a', 40)
) AS t(id, cat, val)
PIVOT (
  count(val) FOR cat IN ('a', 'b')
)
ORDER BY id {code}
id = 2, column b = NULL

 

 



--
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