Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
HIVE-22652 enabled the Top N Key operator to be pushed down through a group by with grouping sets, but I think I have an example where this isn't correct.
If I take the following query:
SELECT a, b, sum(c) FROM t_test_grouping_sets GROUP BY a,b GROUPING SETS (()) ORDER BY b DESC LIMIT 1;
If we were to push the Top N Key operator all the way to the top, it would produce incorrect results. We need to calculate the sum for all rows in the query, so we don't want to limit the rows that are passed through.