This is an automated email from the ASF dual-hosted git repository.

mihaibudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a9ce6c382 [CALCITE-6089] EnumerableSortedAggregate fails with 
ClassCastException: class X cannot be cast to class 
org.apache.calcite.runtime.FlatLists$ComparableList
2a9ce6c382 is described below

commit 2a9ce6c38270b654b3e32380a64576e29189cfc2
Author: 1fanwang <[email protected]>
AuthorDate: Wed Aug 26 01:03:37 2026 -0400

    [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: 
class X cannot be cast to class 
org.apache.calcite.runtime.FlatLists$ComparableList
    
    Signed-off-by: 1fanwang <[email protected]>
---
 .../enumerable/EnumerableSortedAggregateTest.java  | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git 
a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java
 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java
index 6b188b3b35..9cc977544d 100644
--- 
a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java
+++ 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java
@@ -74,6 +74,34 @@ public class EnumerableSortedAggregateTest {
         .throws_("There are not enough rules to produce a node with desired 
properties");
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6089";>[CALCITE-6089]
+   * EnumerableSortedAggregate fails with ClassCastException: class X cannot be
+   * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>. */
+  @Test void sortedAggCountUnionRejectsEmptyGroupSet() {
+    tester(false, new HrSchema())
+        .query("select count(*) as c from ( "
+            + "select * from emps where deptno=10 "
+            + "union all "
+            + "select * from emps where deptno=20)")
+        .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> {
+          planner.removeRule(EnumerableRules.ENUMERABLE_AGGREGATE_RULE);
+          planner.addRule(EnumerableRules.ENUMERABLE_SORTED_AGGREGATE_RULE);
+        })
+        .throws_("There are not enough rules to produce a node with desired 
properties");
+  }
+
+  /** As {@link #sortedAggCountUnionRejectsEmptyGroupSet()}, but with the
+   * default rules. */
+  @Test void sortedAggCountUnion() {
+    tester(false, new HrSchema())
+        .query("select count(*) as c from ( "
+            + "select * from emps where deptno=10 "
+            + "union all "
+            + "select * from emps where deptno=20)")
+        .returnsOrdered("c=4");
+  }
+
   @Test void sortedAggTwoGroupKeys() {
     tester(false, new HrSchema())
         .query(

Reply via email to