[ https://issues.apache.org/jira/browse/CALCITE-3353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16932081#comment-16932081 ]
Danny Chan commented on CALCITE-3353: ------------------------------------- Maybe we should forbidden to match convention(non-logical) nodes for these promotion rules. > ProjectJoinTransposeRule caused AssertionError when creating a new Join > ----------------------------------------------------------------------- > > Key: CALCITE-3353 > URL: https://issues.apache.org/jira/browse/CALCITE-3353 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.20.0 > Reporter: TANG Wen-hui > Assignee: TANG Wen-hui > Priority: Major > > Trying to add ProjectJoinTransposeRule to the rule set to optimize sql (using > VolcanoPlanner). > Get the following exception: > Caused by: java.lang.AssertionErrorCaused by: java.lang.AssertionError at > org.apache.calcite.adapter.enumerable.EnumerableMergeJoin.<init>(EnumerableMergeJoin.java:72) > at > org.apache.calcite.adapter.enumerable.EnumerableMergeJoin.copy(EnumerableMergeJoin.java:112) > at > org.apache.calcite.adapter.enumerable.EnumerableMergeJoin.copy(EnumerableMergeJoin.java:59) > at > org.apache.calcite.rel.rules.ProjectJoinTransposeRule.onMatch(ProjectJoinTransposeRule.java:155) > at > org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:703) > at org.apache.calcite.tools.Programs.lambda$standard$7(Programs.java:466) at > org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:528) at > org.apache.calcite.prepare.Prepare.optimize(Prepare.java:196) at > org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:416) at > org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:310) at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:830) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:610) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:580) > at > org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:247) > at > org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:711) > > ... 22 more > This is because the ProjectJoinTransposeRule can match multiple types of Join > and ProjectJoinTransposeRule creates a new Join using the join.copy() method. > When the rule applied to EnumerableMergeJoin, and the new Join created by > this rule may not meet the requirements of EnumerableMergeJoin. > {code:java} > EnumerableMergeJoin( > RelOptCluster cluster, > RelTraitSet traits, > RelNode left, > RelNode right, > RexNode condition, > Set<CorrelationId> variablesSet, > JoinRelType joinType) { > super(cluster, traits, left, right, condition, variablesSet, joinType); > final List<RelCollation> collations = > traits.getTraits(RelCollationTraitDef.INSTANCE); > assert collations == null || RelCollations.contains(collations, > joinInfo.leftKeys); > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)