Repository navigation
[CALCITE-7863] AggregateReduceFunctionsOnGroupKeysRule fails for constant aggregates on empty input - #5336
[CALCITE-7863] AggregateReduceFunctionsOnGroupKeysRule fails for constant aggregates on empty input#5336xiedeyantu wants to merge 5 commits into
Conversation
…tant aggregates on empty input
| if (!Aggregate.isSimple(aggregate)) { | ||
| return null; | ||
| } | ||
| // A global aggregate may return NULL on empty input even when its |
There was a problem hiding this comment.
Aggregate functions don't always return NULL on empty input. For example COUNT returns 0.
Is there an interface on SqlFunction that reports the value an aggregate function returns on empty input?
There was a problem hiding this comment.
The current rule only supports the MIN, MAX, AVG, and ANY_VALUE aggregate functions, so I don't think the current fix leaves any issues unresolved. Perhaps we could also support COUNT through a special rewrite, but I haven't come up with an efficient approach yet.
I'm not sure if this addresses your concerns. I've added some tests, and I'd appreciate it if you could take another look when you have time.
|



Jira Link
CALCITE-7863
Changes Proposed
See CALCITE-7863