Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3353

ProjectJoinTransposeRule caused AssertionError when creating a new Join

    XMLWordPrintableJSON

Details

    Description

      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.

        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);
        }
      

      Attachments

        Issue Links

          Activity

            People

              winipanda TANG Wen-hui
              winipanda TANG Wen-hui
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 8h 50m
                  8h 50m