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

Join with three tables causes IllegalArgumentException in EnumerableBatchNestedLoopJoinRule

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Issue can be reproduced with the following test (to be added in EnumerableBatchNestedLoopJoinTest):

        @Test void doubleInnerBatchJoinTestSQL() {
          tester(false, new JdbcTest.HrSchema())
              .query("select e.name, d.name as dept, l.name as location "
                  + "from emps e join depts d on d.deptno <> e.salary "
                  + "join locations l on e.empid <> l.empid and d.deptno = l.empid")
              .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> {
                planner.removeRule(EnumerableRules.ENUMERABLE_CORRELATE_RULE);
                planner.addRule(EnumerableRules.ENUMERABLE_BATCH_NESTED_LOOP_JOIN_RULE);
              })
              .explainContains("EnumerableBatchNestedLoopJoin")
              .returnsUnordered("name=Bill; dept=Sales; location=San Francisco",
                  "name=Eric; dept=Sales; location=San Francisco",
                  "name=Sebastian; dept=Sales; location=San Francisco",
                  "name=Theodore; dept=Sales; location=San Francisco");
        }
      

      Which causes:

      Error while executing SQL "explain plan for select e.name, d.name as dept, l.name as location from emps e join depts d on d.deptno <> e.salary join locations l on e.empid <> l.empid and d.deptno = l.empid"
      ...
      Caused by: java.lang.RuntimeException: Error while applying rule EnumerableBatchNestedLoopJoinRule,
      ...
      Caused by: java.lang.IllegalArgumentException: Field #0: empid JavaType(int) does not exist for expression $cor1801
      	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
      ...
      	at org.apache.calcite.adapter.enumerable.EnumerableBatchNestedLoopJoinRule.onMatch(EnumerableBatchNestedLoopJoinRule.java:127)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:229)
      ...
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            1 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 - 40m
                40m

                Slack

                  Issue deployment