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

Assertion error in SemiJoinJoinTransposeRule when Semi-Join has keys from both tables of the bottom Join

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.34.0
    • 1.35.0
    • None

    Description

      The following test will raise the assertion error:

        @Test void testPushSemiJoinPastJoinRuleNotHappensJoinKeysDifferentOrigin() {
          // tests the case where the semijoin is pushed to the right
          final String sql = "select e.ename from emp e, dept d, bonus b\n"
              + "where e.deptno = d.deptno and e.ename = b.ename and d.name = b.job";
          sql(sql)
              .withRule(CoreRules.FILTER_INTO_JOIN,
                  CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN,
                  CoreRules.SEMI_JOIN_JOIN_TRANSPOSE)
              .check();
        }
      
      java.lang.AssertionError
      	at org.apache.calcite.rel.rules.SemiJoinJoinTransposeRule.onMatch(SemiJoinJoinTransposeRule.java:112)
      	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:337)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:556)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:420)
      	at org.apache.calcite.plan.hep.HepPlanner.executeRuleInstance(HepPlanner.java:243)
      	at org.apache.calcite.plan.hep.HepInstruction$RuleInstance$State.execute(HepInstruction.java:178)
      	at org.apache.calcite.plan.hep.HepPlanner.lambda$executeProgram$0(HepPlanner.java:211)
      	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
      	at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:210)
      	at org.apache.calcite.plan.hep.HepProgram$State.execute(HepProgram.java:118)
      	at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:205)
      	at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:191)
      	at org.apache.calcite.test.RelOptFixture.checkPlanning(RelOptFixture.java:379)
      	at org.apache.calcite.test.RelOptFixture.check(RelOptFixture.java:330)
      	at org.apache.calcite.test.RelOptFixture.check(RelOptFixture.java:314)
      	at org.apache.calcite.test.RelOptRulesTest.testPushSemiJoinPastJoinRuleNotHappensJoinKeysDifferentOrigin(RelOptRulesTest.java:2650)
      

      The problem here is that the case when top-most Semi-Join has join keys from both tables of the bottom Join is considered impossible, though it happens in practice.

      Attachments

        Issue Links

          Activity

            People

              rkondakov Roman Kondakov
              rkondakov Roman Kondakov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: