You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2017/11/16 01:00:00 UTC

[jira] [Commented] (CALCITE-2039) AssertionError when pushing project to ProjectableFilterableTable

    [ https://issues.apache.org/jira/browse/CALCITE-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254574#comment-16254574 ] 

Julian Hyde commented on CALCITE-2039:
--------------------------------------

Thanks for your test case, [~eolivelli]. Yours uses UPDATE, but I was able to convert it into a test case based on SELECT, {{ScannableTableTest.testCannotPushProject}}. Will commit shortly.

> AssertionError when pushing project to ProjectableFilterableTable
> -----------------------------------------------------------------
>
>                 Key: CALCITE-2039
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2039
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.14.0
>            Reporter: Alexey Roytman
>            Assignee: Michael Mior
>         Attachments: CALCITE-2039.zip, PlannerExampleTest.java, PlannerExampleTest.java, calcite_2039_eclipse_project.zip
>
>
> 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, ...")
> {code}
> 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
> {code}
> causes an exception:
> {noformat}
> 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)
>         ...
> {noformat}
> 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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)