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

ArrayIndexOutOfBoundsException when inferring more equal conditions from join condition for semi join

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.31.0
    • None

    Description

      The following test can reproduce the exception.

        @Test void testJoinConditionPushdown4() {
          final Function<RelBuilder, RelNode> relFn = b -> {
            RelNode left = b.scan("EMP")
                .project(
                    b.field("DEPTNO"),
                    b.field("ENAME"))
                .build();
            RelNode right = b.scan("DEPT")
                .project(
                    b.field("DEPTNO"),
                    b.field("DNAME"))
                .build();
      
            b.push(left).push(right);
      
            RexInputRef ref1 = b.field(2, 0, "DEPTNO");
            RexInputRef ref2 = b.field(2, 1, "DEPTNO");
            RexInputRef ref3 = b.field(2, 1, "DNAME");
      
            RexCall cond1 = (RexCall) b.equals(ref1, ref2);
            RexCall cond2 = (RexCall) b.equals(ref1, ref3);
      
            RexNode cond = b.and(cond1, cond2);
            return b.semiJoin(cond)
                .project(b.field(0))
                .build();
          };
      
          relFn(relFn)
              .withRule(
                  CoreRules.JOIN_PUSH_EXPRESSIONS,
                  CoreRules.JOIN_CONDITION_PUSH,
                  CoreRules.SEMI_JOIN_PROJECT_TRANSPOSE,
                  CoreRules.JOIN_REDUCE_EXPRESSIONS,
                  CoreRules.FILTER_REDUCE_EXPRESSIONS)
              .check();
        }
      

      Attachments

        Issue Links

          Activity

            People

              Chunwei Lei Chunwei Lei
              Chunwei Lei Chunwei Lei
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 1.5h
                  1.5h