[ https://issues.apache.org/jira/browse/CALCITE-3353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16934151#comment-16934151 ]
Stamatis Zampetakis commented on CALCITE-3353: ---------------------------------------------- Hey [~danny0405], The snippet above was just for demonstration purposes. I was not suggesting to copy it as is in our rule(s); in particular since the majority of our rules target {{Convention.NONE}}. To be more precise for this particular use-case we could simply keep the same name (i.e., {{INSTANCE}}) but instantiate it with a new constructor only for logical project/join. The impact of your suggestions are wider than the scope of this issue so I guess it is more appropriate to discuss this on the dev list. Moreover, I find that it is very related to the [discussion|https://lists.apache.org/thread.html/da1860f99f8bfd6ec7d26626c428ce1c55480e7c61ae7f83060a40c2@%3Cdev.calcite.apache.org%3E] that we had a couple of months ago so it may be worth resurrecting that thread. > 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 > Labels: pull-request-available > Time Spent: 1h 50m > Remaining Estimate: 0h > > 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)