[CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList - #5222
Open
1fanwang wants to merge 1 commit into
Conversation
mihaibudiu
approved these changes
Aug 25, 2026
mihaibudiu
left a comment
Contributor
There was a problem hiding this comment.
I approved, but please simplify the useless comments.
| * EnumerableSortedAggregate fails with ClassCastException: class X cannot be | ||
| * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>. | ||
| * | ||
| * <p>The aggregate has no group key, so since |
Contributor
There was a problem hiding this comment.
I don't think we care about what used to happen previously. We are not keeping a log of all past bugs.
Contributor
|
please squash the commits for merging |
…n: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
force-pushed
the
calcite-6089-sorted-agg-union
branch
from
August 26, 2026 05:03
fd7f2d0 to
6319f71
Compare
|
rubenada
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Jira Link
CALCITE-6089
Changes Proposed
Counting rows over a
UNION ALLfailed at runtime when the sorted aggregate wasused:
The query now returns
c=4.The aggregate has no group key. The rule used to convert it anyway, and
comparing the zero-length keys threw. CALCITE-6087 made the rule decline an
empty group set, so no sorted aggregate is produced, the planner uses the
regular aggregate, and the query succeeds. That fix therefore closed this issue
too, so this PR adds only the regression tests requested when #5202 merged.
Two tests, following the pattern that patch established. One forces the sorted
rule and asserts the planner now rejects the plan; the other runs the query with
the usual rule set and asserts the result.
Testing
Running the suite on this branch, which is current main plus the two new tests:
Reverting only the one-line rule change from CALCITE-6087, and keeping the new
tests, reproduces the original failure:
Are there any user-facing changes?
No. Tests only.