Aleksandr Efimov created IMPALA-15699:
-----------------------------------------
Summary: Calcite planner: fix GROUPING_ID for repeated grouping
sets
Key: IMPALA-15699
URL: https://issues.apache.org/jira/browse/IMPALA-15699
Project: IMPALA
Issue Type: Bug
Components: Frontend
Reporter: Aleksandr Efimov
Assignee: Aleksandr Efimov
The Calcite planner rejects GROUPING_ID when repeated grouping sets include a
partial set that omits one of its arguments.
{code:sql}
SELECT a AS ka, b AS kb, grouping_id(a,b) AS gid, count(*) AS n
FROM (SELECT cast(1 AS int) a, cast(10 AS int) b, cast(5 AS int) v
UNION ALL SELECT 2, 20, 7) t
GROUP BY GROUPING SETS ((b), (a,b), (), (b), ());
{code}
Actual: native plan conversion fails with "A is not a grouping expression in
grouping_id(A, B)".
Expected: eight rows. The (a,b) rows have gid=0. Each (b) row occurs twice with
gid=2. The grand-total row (NULL, NULL, 3, 2) also occurs twice. Reversing the
GROUPING_ID argument order must reverse the corresponding mask bits. HAVING
grouping_id(a,b)=3 should retain both grand-total rows.
This is separate from IMPALA-14483, which concerns deduplication of repeated
grouping sets in the original planner.
Reproduced on master 234bd0001e33.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)