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

RelBuilder.join should convert Correlate to Join if correlation variable is unused

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.28.0
    • core

    Description

      We generate correlated join when no correlate variable is present on the right side. However, this could be simplified to emit a normal join.

      Given:

      final RelNode rel = builder
          .scan("EMP")
          .variable(v)
          .scan("DEPT")
          .join(JoinRelType.LEFT,
              builder.equals(builder.field(2, 0, "SAL"),
                  builder.literal(1000)),
              ImmutableSet.of(v.get().id))
          .build();
      

      Currently the following is emitted:

      LogicalFilter(condition=[=($7, $8)])
        LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
          LogicalTableScan(table=[[scott, EMP]])
          LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
            LogicalTableScan(table=[[scott, DEPT]])
      

      After the changes the following will be emitted:

      LogicalJoin(condition=[=($7, $8)], joinType=[left])
        LogicalTableScan(table=[[scott, EMP]])
        LogicalTableScan(table=[[scott, DEPT]])
      

      Attachments

        Issue Links

          Activity

            People

              jamesstarr James Starr
              jamesstarr James Starr
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 20m
                  20m