You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jesus Camacho Rodriguez (Jira)" <ji...@apache.org> on 2020/03/17 03:33:00 UTC

[jira] [Resolved] (CALCITE-3862) Materialized view rewriting algorithm throws IndexOutOfBoundsException

     [ https://issues.apache.org/jira/browse/CALCITE-3862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesus Camacho Rodriguez resolved CALCITE-3862.
----------------------------------------------
    Fix Version/s: 1.23.0
       Resolution: Fixed

Fixed in https://github.com/apache/calcite/commit/0e345fd8d9eaa4223ada8ecc2987a7c82cb0d2b8. Thanks [~vgarg]!

> Materialized view rewriting algorithm throws IndexOutOfBoundsException
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-3862
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3862
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Vineet Garg
>            Assignee: Vineet Garg
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.23.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> *Repro*
> {code:sql}
> +    sql("select \"deptno\", \"empid\", \"salary\", sum(1) "
> +            + "from \"emps\"\n"
> +            + "group by \"deptno\", \"empid\", \"salary\"",
> +        "select sum(1) "
> +            + "from \"emps\"\n"
> +            + "join \"depts\" on \"depts\".\"deptno\" = \"empid\" group by \"empid\", \"depts\".\"deptno\"")
> +        .withResultContains(
> +            "EnumerableCalc(expr#0..1=[{inputs}], EXPR$0=[$t1])\n"
> +                + "  EnumerableAggregate(group=[{1}], EXPR$0=[$SUM0($3)])\n"
> +                + "    EnumerableHashJoin(condition=[=($1, $4)], joinType=[inner])\n"
> +                + "      EnumerableTableScan(table=[[hr, m0]])")
> +        .ok();
> {code}
> *Error*
> {code}
> Next exception 1: [CIRCULAR REFERENCE SQLException]
>             Next exception 2: [CIRCULAR REFERENCE RuntimeException]
>             Next exception 3: java.lang.IndexOutOfBoundsException: index (2) must be less than size (2)
>                 at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
>                 at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
>                 at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
>                 at org.apache.calcite.rex.RexBuilder.makeInputRef(RexBuilder.java:853)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewRule$3.visitInputRef(MaterializedViewRule.java:1217)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewRule$3.visitInputRef(MaterializedViewRule.java:1181)
>                 at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
>                 at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewRule.shuttleReferences(MaterializedViewRule.java:1242)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewAggregateRule.rewriteView(MaterializedViewAggregateRule.java:728)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewRule.perform(MaterializedViewRule.java:485)
>                 at org.apache.calcite.rel.rules.materialize.MaterializedViewOnlyAggregateRule.onMatch(MaterializedViewOnlyAggregateRule.java:63)
>                 at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:238)
>                 at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:540)
>                 at org.apache.calcite.tools.Programs.lambda$standard$3(Programs.java:286)
>                 at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:346)
>                 at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:165)
>                 at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:290)
>                 at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:207)
>                 at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:634)
>                 at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:498)
>                 at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:468)
>                 at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231)
>                 at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:550)
>                 at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
>                 at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)