Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.35.0
-
None
-
None
Description
The problem can be reproduced with this test (to be added e.g. into EnumerableSortedAggregateTest.java):
@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)") .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> { planner.removeRule(EnumerableRules.ENUMERABLE_AGGREGATE_RULE); planner.addRule(EnumerableRules.ENUMERABLE_SORTED_AGGREGATE_RULE); }) .explainContains( "EnumerableSortedAggregate(group=[{}], c=[COUNT()])\n" + " EnumerableUnion(all=[true])\n" + " EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t1):INTEGER NOT NULL], expr#6=[10], expr#7=[=($t5, $t6)], commission=[$t4], $condition=[$t7])\n" + " EnumerableTableScan(table=[[s, emps]])\n" + " EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t1):INTEGER NOT NULL], expr#6=[20], expr#7=[=($t5, $t6)], commission=[$t4], $condition=[$t7])\n" + " EnumerableTableScan(table=[[s, emps]])") .returnsOrdered( "c=4"); }
Which fails with:
... Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList (java.lang.Integer is in module java.base of loader 'bootstrap'; org.apache.calcite.runtime.FlatLists$ComparableList is in unnamed module of loader 'app') at Baz$6.compare(Unknown Source) at org.apache.calcite.linq4j.EnumerableDefaults$SortedAggregateEnumerator.moveNext(EnumerableDefaults.java:938) at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.<init>(Linq4j.java:679) at org.apache.calcite.linq4j.Linq4j.enumeratorIterator(Linq4j.java:97) ...
The same test with EnumerableAggregate (instead of EnumerableSortedAggregate) will execute the query correctly.
Attachments
Issue Links
- is related to
-
CALCITE-6087 EnumerableSortedAggregate returns incorrect result when input is empty
- Open
-
CALCITE-4008 Implement Code generation for EnumerableSortedAggregate
- Closed