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

Anton Haidai commented on CALCITE-3052:
---------------------------------------

[~jcamachorodriguez], thank you for your help!
While the error is still reproducible on my environment, I believe, that you 
identified the issue correctly because the rule can move through the fixed code 
now and it fails much further, here is the stacktrace:
{code}
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
        at 
com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:60)
        at org.apache.calcite.rex.RexBuilder.makeInputRef(RexBuilder.java:841)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule$3.visitInputRef(AbstractMaterializedViewRule.java:2448)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule$3.visitInputRef(AbstractMaterializedViewRule.java:2412)
        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.AbstractMaterializedViewRule.shuttleReferences(AbstractMaterializedViewRule.java:2473)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule.access$900(AbstractMaterializedViewRule.java:105)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewAggregateRule.rewriteView(AbstractMaterializedViewRule.java:1552)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule.perform(AbstractMaterializedViewRule.java:522)
        at 
org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewProjectAggregateRule.onMatch(AbstractMaterializedViewRule.java:1777)
        at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
{code}

Here is the dump of variables involved:
{code}
queryAggregate.getRowType(): RecordType(VARCHAR team, DOUBLE EXPR$0, BIGINT 
EXPR$1, BIGINT EXPR$2, BIGINT EXPR$3, BIGINT EXPR$4)

queryAggregate.getGroupCount(): 1

queryAggregate.getAggCallList(): 5

result.getRowType(): RecordType(VARCHAR team, BIGINT EXPR$1, BIGINT EXPR$2)

topExprs: "$0" "$2" "$3"

expr: "$3"

rewrittenExpr: $4

viewExprs: {$0=[6], $1=[5], $2=[0], $3=[1], $4=[2], $5=[3], $6=[4]}

rewritingMapping: [size=3, sourceCount=7, targetCount=6, elements=[1:2, 2:3, 
6:0]]
{code}


> Error while applying rule MaterializedViewAggregateRule(Project-Aggregate): 
> ArrayIndexOutOfBoundsException
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3052
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3052
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.19.0
>            Reporter: Anton Haidai
>            Assignee: Jesus Camacho Rodriguez
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> *Materialized views enabled:*
> # {{select avg(grade), count\(*), max(grade), sum(grade), min(grade), team 
> from students group by team}}
> # {{select avg(grade), count\(*), max(grade), sum(grade), min(grade), team, 
> faculty from students group by faculty, team}},
> *Query:*
> # {{select count\(*), team from students group by team}}
> *Error* (stacktrace is obtained using the current *master* branch: 
> "247c7d4f76"):
> {noformat}
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
>       at 
> com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:60)
>       at org.apache.calcite.rex.RexBuilder.makeInputRef(RexBuilder.java:841)
>       at 
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewAggregateRule.rewriteView(AbstractMaterializedViewRule.java:1507)
>       at 
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule.perform(AbstractMaterializedViewRule.java:522)
>       at 
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewProjectAggregateRule.onMatch(AbstractMaterializedViewRule.java:1776)
>       at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
>       ... 71 common frames omitted
> {noformat}
> Reproducible only if both Materialization views listed are enabled: any 
> single one of these two could be successfully used with the query without any 
> errors. Looks like is is reproducible when AbstractMaterializedViewRule is 
> trying to rewrite one materialized view using the another materialized view.
> Currently, I'm trying to reproduce the issue in "MaterializationTest": 
> without a success so far, I'll update the ticket if I'll find a working way 
> to reproduce the issue in the test will be discovered.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to