[CALCITE-6087] EnumerableSortedAggregate returns incorrect result when input is empty - #5202
Conversation
|
Thank you for the contribution! Please take a look to jira discussion. |
|
Thanks for the contribution @1fanwang ! |
thanks for the pointer @xuzifu666 done in d3b829a |
|
Thanks @1fanwang , LGTM. I just left some minor comment. |
ec5bec9 to
35d86fd
Compare
…n input is empty Signed-off-by: 1fanwang <1fannnw@gmail.com>
35d86fd to
3d2df15
Compare
|
|
Thanks for the patch @1fanwang ! |



Jira Link
CALCITE-6087
Changes Proposed
When a query applies
MAXorCOUNTto empty input, a sorted global aggregate returns no row. SQL requires one row containingNULLand0.Sorted grouping emits one row per observed key, but 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=0m=null; c=0Raw logs
With the pre-fix parent version of
EnumerableSortedAggregateRule:With this PR, the standard-path assertion observed
m=null; c=0: