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: [email protected]
For additional commands, e-mail: [email protected]