[ 
https://issues.apache.org/jira/browse/SPARK-57715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18091852#comment-18091852
 ] 

Nikita Awasthi commented on SPARK-57715:
----------------------------------------

User 'miland-db' has created a pull request for this issue:
https://github.com/apache/spark/pull/56808

> 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
>            Priority: Major
>
> 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]

Reply via email to