Grouping sets with having clause returns the wrong result when the condition of having contained conflicting naming. See the below example:
The `b` in `having b > 10` should be resolved as `T.b` not `sum(a)`, so the right result should be
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.
Other systems worked as expected, I checked PostgreSQL 9.6 and MS SQL Server 2017.
For Apache Spark 2.0.2 ~ 2.3.4, the following query is tested.