Yaoxuan Wu created FLINK-40947:
----------------------------------

             Summary: ROLLUP / CUBE / GROUPING SETS with () return no 
grand-total row on an empty input
                 Key: FLINK-40947
                 URL: https://issues.apache.org/jira/browse/FLINK-40947
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 2.3.0, 2.0.1, 2.4.0
            Reporter: Yaoxuan Wu


{code:java}
CREATE TEMPORARY VIEW e AS SELECT * FROM (VALUES (1, 10)) AS v(k, c) WHERE k > 
5;   -- emptySELECT k, COUNT(*) FROM e GROUP BY ROLLUP(k);                -- 
Flink: no rows   expected: (NULL, 0)
SELECT k, COUNT(*) FROM e GROUP BY GROUPING SETS ((k), ());  -- Flink: no rows  
 expected: (NULL, 0)
SELECT k, COUNT(*) FROM e GROUP BY CUBE(k);                  -- Flink: no rows  
 expected: (NULL, 0)
SELECT COUNT(*) FROM e GROUP BY GROUPING SETS (());          -- (0), correct
SELECT COUNT(*) FROM e;                                      -- (0), correct 
{code}
GROUPING SETS ((k), ()) is the union of GROUP BY k and GROUP BY (), and GROUP 
BY () over an empty input returns one row. Flink returns that row for GROUPING 
SETS (()) alone, but drops it once another grouping set is present. The same 
happens with a filesystem table that has no rows.

Also reproduces on current master (2.4-SNAPSHOT, a47e4bf).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to