[ https://issues.apache.org/jira/browse/CALCITE-3848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17055459#comment-17055459 ]
Vineet Garg commented on CALCITE-3848: -------------------------------------- [~jcamachorodriguez] can you take a look please? > Materialized view rewriting fails for mv consisting of group by on join keys > ---------------------------------------------------------------------------- > > Key: CALCITE-3848 > URL: https://issues.apache.org/jira/browse/CALCITE-3848 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Vineet Garg > Assignee: Vineet Garg > Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > Test case > {code:java} > + @Test public void testAggregateOnJoinKeys() { > + checkMaterialize( > + "select \"deptno\", \"empid\", \"salary\"\n" > + + "from \"emps\"\n" > + + "group by \"deptno\", \"empid\", \"salary\"", > + "select \"empid\", \"depts\".\"deptno\" \n" > + + "from \"emps\"\n" > + + "join \"depts\" on \"depts\".\"deptno\" = \"empid\" group by > \"empid\", \"depts\".\"deptno\"", > + HR_FKUK_MODEL, > + CalciteAssert.checkResultContains( > + "EnumerableCalc(expr#0=[{inputs}], empid=[$t0], empid0=[$t0])\n" > + + " EnumerableAggregate(group=[{1}])\n" > + + " EnumerableHashJoin(condition=[=($1, $3)], > joinType=[inner])\n" > + + " EnumerableTableScan(table=[[hr, m0]])")); > + } > + > {code} > Error: > {code} > Caused by: java.lang.RuntimeException: Error while applying rule > MaterializedViewAggregateRule(Aggregate), args > [rel#64476:EnumerableAggregate.ENUMERABLE.[](input=RelSubset#64475,group={0, > 1})] > at > org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:260) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:634) > 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) > ... 16 more > Next exception 1: [CIRCULAR REFERENCE SQLException] > Next exception 2: [CIRCULAR REFERENCE RuntimeException] > Next exception 3: > org.apache.calcite.util.mapping.Mappings$NoElementException: source #0 has no > target in mapping [size=1, sourceCount=2, targetCount=7, elements=[1:1]] > at > org.apache.calcite.util.mapping.Mappings$AbstractMapping.getTarget(Mappings.java:881) > at > org.apache.calcite.rel.rules.materialize.MaterializedViewAggregateRule.rewriteView(MaterializedViewAggregateRule.java:677) > 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:233) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:634) > 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) > ... 16 more > Caused by: [CIRCULAR REFERENCE PlaceholderException] > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)