Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
Impala 3.0
-
None
-
ghx-label-3
Description
A recent change appears to have caused a test to expect the wrong rewritten SQL in spillable-buffer-sizing.test.
# Mid NDV aggregation - should scale down buffers to intermediate size. select straight_join l_orderkey, o_orderstatus, count(*) from tpch_parquet.lineitem join tpch_parquet.orders on o_orderkey = l_orderkey group by 1, 2 having count(*) = 1 ---- DISTRIBUTEDPLAN Max Per-Host Resource Reservation: Memory=82.00MB Threads=7 Per-Host Resource Estimates: Memory=244MB Analyzed query: SELECT -- +straight_join l_orderkey, o_orderstatus, count(*) FROM tpch_parquet.lineitem INNER JOIN tpch_parquet.orders ON o_orderkey = l_orderkey GROUP BY CAST(1 AS INVALID_TYPE), CAST(2 AS INVALID_TYPE) HAVING count(*) = CAST(1 AS BIGINT)
Correct rewritten SQL:
Analyzed query: SELECT -- +straight_join l_orderkey, o_orderstatus, count(*) FROM tpch_parquet.lineitem INNER JOIN tpch_parquet.orders ON o_orderkey = l_orderkey GROUP BY l_orderkey, o_orderstatus HAVING count(*) = CAST(1 AS BIGINT)
The same problem occurs in max-rows-test.test.
The problem is due to the existence of two copies of the grouping expressions. The toSql() function used the original, unanalyzed copy, not the rewritten copy with ordinal replacements.