Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.16.0
-
None
Description
Optimizer rule AggregateProjectPullUpConstantsRule removes constant keys from an Aggregate. However, this rules never removes the last column, because Aggregate([]) returns 1 row even if its input is empty.
An enhancement could be done to AggregateProjectPullUpConstantsRule so that it removes all constant keys:
- Remove all constant keys from an Aggregate
- (Only)When no key is left from previous step (Aggregate becomes Aggregate([])), add a filter to the Aggregate([]) so that it returns empty dataset if its input is empty.
E.g.
SELECT 'abc' FROM table_name GROUP BY ('abc')
will be translated to:
SELECT 'abc' FROM table_name GROUP BY () having count(*)>0
Attachments
Issue Links
- is related to
-
CALCITE-4597 Allow RelNodes to have an empty row type (zero fields)
- Open
- links to