You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yuanjian Li (Jira)" <ji...@apache.org> on 2020/05/08 16:25:00 UTC

[jira] [Updated] (SPARK-31663) Grouping sets with having clause returns the wrong result

     [ https://issues.apache.org/jira/browse/SPARK-31663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yuanjian Li updated SPARK-31663:
--------------------------------
    Labels: correct  (was: )

> Grouping sets with having clause returns the wrong result
> ---------------------------------------------------------
>
>                 Key: SPARK-31663
>                 URL: https://issues.apache.org/jira/browse/SPARK-31663
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.4.5, 3.0.0
>            Reporter: Yuanjian Li
>            Priority: Major
>              Labels: correct
>
> Grouping sets with having clause returns the wrong result when the condition of having contained conflicting naming. See the below example:
> {quote}
> select sum(a) as b FROM VALUES (1, 10), (2, 20) AS T(a, b) group by GROUPING SETS ((b), (a, b)) having b > 10
> {quote}
> The `b` in `having b > 10` should be resolved as `T.b` not `sum(a)`, so the right result should be
> {quote}
> +---+
> | b|
> +---+
> | 2|
> | 2|
> +---+
> {quote}
> instead of an empty result.
> The root cause is similar to SPARK-31519, it's caused by we parsed HAVING as Filter(..., Agg(...)) and resolved these two parts in different rules. The CUBE and ROLLUP have the same issue.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org