Conforming to SQL Standard for GROUP BY set>
Details
| Detail name | Value |
|---|---|
| Changelog Number | 8278 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | EXASOL 6.0.0, Exasol 6.1.0, Exasol 6.2.rc1 |
| Fix Versions | Exasol 6.2.0 |
| Resolution Date | 2019-07-11 |
In the past, GROUP BY <empty grouping set> or GROUP BY () has been treated as GROUP BY TRUE.
When the table is not empty, the behavior of these two clauses is identical. However, if the table is empty, the GROUP BY () clause should return a single column with NULL in the result table while GROUP BY TRUE does not return any rows.
How to reproduce
The queries below returned empty result. With this fix, they return a single row with NULL value.
CREATE SCHEMA test; CREATE TABLE tab (i INTEGER); select true from tab group by (); select true from tab having true; SELECT DISTINCT TRUE FROM tab group by (); SELECT DISTINCT TRUE FROM tab having true; select sum(i) from tab group by (); select sum(i) from tab having true;
Note that when a having clause is used without a GROUP BY then GROUP BY () is implied.
Known Issue
The following query still does not conform to the SQL Standard and will require additional effort to fix.
select count(*) from tab group by grouping sets ((i), ());
When the table tab is empty, the above query does not return any rows where it should return a single row with NULL as per SQL Standard.
There is no workaround for this issue.