You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Anupam Yadav (Jira)" <ji...@apache.org> on 2026/06/09 19:05:00 UTC
[jira] [Commented] (SPARK-57346) [Analyzer++] HAVING/ORDER BY aggregates over GROUPING SETS give wrong results
[ https://issues.apache.org/jira/browse/SPARK-57346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18087730#comment-18087730 ]
Anupam Yadav commented on SPARK-57346:
--------------------------------------
I'd like to work on this. Thanks!
> [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
> Priority: Major
>
> 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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org