You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GROUPING SETS (()) returns no rows on empty input #22040
When a query uses GROUP BY GROUPING SETS(()) and the input relation is empty, DataFusion returns 0 rows. This is incorrect.
According to SQL semantics, the empty grouping set () represents a global aggregate, so it should still produce exactly one output row even when there are no input rows.
In practice, this affects queries such as:
SELECT SUM(empno)
FROM emp
WHERE false
GROUP BY GROUPING SETS(());
The current result is an empty result set, but it should return one row with NULL for SUM(empno).
To Reproduce
Steps to reproduce the behavior:
Create a table and insert data.
Run a query with WHERE false so the input becomes empty.
Use GROUP BY GROUPING SETS(()).
Example:
CREATE TABLE emp (
empno INT PRIMARY KEY,
ename VARCHAR(10) NOT NULL,
job VARCHAR(10),
mgr INT,
hiredate DATE,
sal DECIMAL(10,2),
comm DECIMAL(10,2),
deptno INT
);
INSERT INTO emp (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES
(7369, 'SMITH', 'CLERK', 7902, '1980-12-17', 800.00, NULL, 20);
SELECT SUM(empno)
FROM emp
WHERE false
GROUP BY GROUPING SETS(());
Activity
xiedeyantu commentedon May 6, 2026
take
Prevent empty grouping sets from being eliminated on empty input (apa…
Prevent empty grouping sets from being eliminated on empty input (apa…