Description
When my table implements interface ProjectableFilterableTable, and I execute a query that contains column but also an expression, with assertions enabled (java -ea), I get an AssertionError at Mappings.create(Mappings.java:64).
The following query (notice the "select 0 as c1, ...")
select 0 as c1, D101.c1 as c3, D101.c2 as c4, D101.c3 as c5 from ( select T1000001.Category as c1, T1000001.Revenue as c2, T1000001."YEAR" as c3 from ( select "YEAR", Category, "MONTH", Territory, Quarter, Sub_Category, Age_Group, Gender, Country, Revenue, Num_Of_Orders, "DATE" from XSchema.HDP) T1000001) D101
causes an exception:
java.lang.AssertionError at org.apache.calcite.util.mapping.Mappings.create(Mappings.java:64) at org.apache.calcite.rel.core.Project.getMapping(Project.java:277) at org.apache.calcite.rel.core.Project.getMapping(Project.java:257) at org.apache.calcite.rel.rules.ProjectTableScanRule.apply(ProjectTableScanRule.java:100) at org.apache.calcite.rel.rules.ProjectTableScanRule$3.onMatch(ProjectTableScanRule.java:83) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:212) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650) at org.apache.calcite.tools.Programs$5.run(Programs.java:326) at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:387) at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:188) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:321) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:786) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) ...
In the Mappings.create(), mappingType is INVERSE_SURJECTION, and "assert sourceCount >= targetCount" throws the exception, because sourceCount is 3, and targetCount is 4.
At the frame above, in Project.getMapping(), "projects" are: [0, $1, $2, $0] (1st is RexLiteral, others are RexInputRef). At the frame above, in EnumerableProject.getMapping(), getInput().getRowType() has only 3 fields in the table.
I have a reproduction case (in Java) but it's not within a Calcite standard.
Attachments
Attachments
Issue Links
- is related to
-
CALCITE-3405 Prune columns for ProjectableFilterableTable when Project is not simple mapping
- Closed