Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.30.0
-
None
-
None
Description
when i defined a table
"implements ProjectableFilterableTable, TranslatableTable"
then the sql
select count(1) from `database`.`table` where c1 is not null;
may trigger a error like
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String at Baz$1.apply(janino650997550716152417.java:51) at Baz$1.apply(janino650997550716152417.java) at org.apache.calcite.adapter.enumerable.BasicAggregateLambdaFactory$AccumulatorAdderSeq.apply(BasicAggregateLambdaFactory.java:81) at org.apache.calcite.linq4j.EnumerableDefaults.aggregate(EnumerableDefaults.java:133) at org.apache.calcite.linq4j.DefaultEnumerable.aggregate(DefaultEnumerable.java:107) at Baz.bind(janino650997550716152417.java:68) at org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:363) at org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:323)
the janino code like
public org.apache.calcite.linq4j.Enumerable bind(final org.apache.calcite.DataContext root) { final org.apache.calcite.rel.RelNode v1stashed = (org.apache.calcite.rel.RelNode) root.get("v1stashed"); final org.apache.calcite.interpreter.Interpreter interpreter = new org.apache.calcite.interpreter.Interpreter( root, v1stashed); java.util.List accumulatorAdders = new java.util.LinkedList(); accumulatorAdders.add(new org.apache.calcite.linq4j.function.Function2() { public Record1_0 apply(Record1_0 acc, String in) { acc.f0++; return acc; } public Record1_0 apply(Object acc, Object in) { return apply( (Record1_0) acc, (String) in); } } ); org.apache.calcite.adapter.enumerable.AggregateLambdaFactory lambdaFactory = new org.apache.calcite.adapter.enumerable.BasicAggregateLambdaFactory( new org.apache.calcite.linq4j.function.Function0() { public Object apply() { long COUNTa0s0; COUNTa0s0 = 0L; Record1_0 record0; record0 = new Record1_0(); record0.f0 = COUNTa0s0; return record0; } } , accumulatorAdders); return org.apache.calcite.linq4j.Linq4j.singletonEnumerable(org.apache.calcite.runtime.Enumerables.slice0(interpreter).aggregate(lambdaFactory.accumulatorInitializer().apply(), lambdaFactory.accumulatorAdder(), lambdaFactory.singleGroupResultSelector(new org.apache.calcite.linq4j.function.Function1() { public long apply(Record1_0 acc) { return acc.f0; } public Object apply(Object acc) { return apply( (Record1_0) acc); } } ))); } public Class getElementType() { return long.class; }
and when you define a table
"implements FilterableTable, TranslatableTable"
it will be ok!