Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.3.0, 2.0.0
-
None
Description
Consider the following query:
SELECT key, value, GROUPING__ID, count(*) FROM T1 GROUP BY key, value GROUPING SETS ((), (key)) HAVING GROUPING__ID = 1
This query will not return results.
The reason is that a "constant" placeholder is introduced by SemanticAnalyzer for the GROUPING__ID column. At execution time, this placeholder is replaced by the actual value of the GROUPING__ID. As the column is a constant, the Hive optimizer (combination of PPD and constant folding) will evaluate statically whether the condition is met or not, leading to incorrect results.
We should be able to recognize the placeholder and avoid PPD pushing the filter predicate to the GroupBy operator.