[CALCITE-6087] EnumerableSortedAggregate returns incorrect result when input is empty - #5202
[CALCITE-6087] EnumerableSortedAggregate returns incorrect result when input is empty#52021fanwang wants to merge 1 commit into
Conversation
…n input is empty Signed-off-by: 1fanwang <1fannnw@gmail.com>
|
|
Thank you for the contribution! Please take a look to jira discussion. |
| .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> { | ||
| planner.removeRule(EnumerableRules.ENUMERABLE_AGGREGATE_RULE); | ||
| planner.addRule(EnumerableRules.ENUMERABLE_SORTED_AGGREGATE_RULE); | ||
| planner.addRule(EnumerableRules.ENUMERABLE_AGGREGATE_RULE); |
There was a problem hiding this comment.
why adding this rule if it was just removed a few lines above?
UPDATE: ok, I understand, if we don't do it the query is un-implementable. But now I wonder if we can be really sure to be testing the fix here, or maybe it's the standard ENUMERABLE_AGGREGATE_RULE that kicks in....
I wonder if a more suitable test would be testing the without any hook (to confirm it passes with ENUMERABLE_AGGREGATE_RULE; and then testing it with Hook to remove ENUMERABLE_AGGREGATE_RULE, add ENUMERABLE_SORTED_AGGREGATE_RULE and verify that it fails because it cannot be implemented?
|
Thanks for the contribution @1fanwang ! |



Jira Link
CALCITE-6087
Changes Proposed
An empty global aggregate implemented by
EnumerableSortedAggregatereturns no row. For example,MAXandCOUNTover an empty input should return one row containingNULLand0, but the result is empty.Sorted grouping emits one row per observed key, and a global aggregate has no grouping key. The sorted aggregate rule now declines an empty group set so
EnumerableAggregatehandles it through its zero-key singleton path. Grouped sorted aggregates are unchanged.Testing
m=null; c=0Raw logs
Formatting, Checkstyle, and forbidden-apis checks pass.