Stefan Kandic created SPARK-57346:
-------------------------------------
Summary: [Analyzer++] HAVING/ORDER BY aggregates over GROUPING
SETS give wrong results
Key: SPARK-57346
URL: https://issues.apache.org/jira/browse/SPARK-57346
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 4.2.0
Reporter: Stefan Kandic
SUM(b) in HAVING/ORDER BY above a GROUPING SETS/CUBE/ROLLUP aggregate resolves
grouping column b to the Expand-output copy (NULL for rolled-up groups) instead
of the original column. HAVING filters out rolled-up rows; ORDER BY sorts them
as NULL.
ORDER BY repro:
SELECT a, b, SUM(b) FROM VALUES (1,10),(1,20),(2,30) AS t(a,b)
GROUP BY CUBE(a, b) ORDER BY SUM(b);
HAVING repro:
SELECT a, SUM(b) FROM VALUES (1,10),(1,20),(2,30) AS t(a,b)
GROUP BY ROLLUP(a, b) HAVING SUM(b) > 25;
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]