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

Extend IntersectToSemiJoinRule to support n-way inputs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.40.0
    • None

    Description

      SQL:

      select ename from emp where deptno = 10
      intersect
      select ename from emp where deptno = 20
      intersect
      select ename from emp where deptno = 30 

      Plan before:

      LogicalIntersect(all=[false])
        LogicalProject(ENAME=[$1])
          LogicalFilter(condition=[=($7, 10)])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
        LogicalProject(ENAME=[$1])
          LogicalFilter(condition=[=($7, 20)])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
        LogicalProject(ENAME=[$1])
          LogicalFilter(condition=[=($7, 30)])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]]) 

      Plan after:

      LogicalAggregate(group=[{0}])
        LogicalJoin(condition=[IS NOT DISTINCT FROM($0, $1)], joinType=[semi])
          LogicalJoin(condition=[IS NOT DISTINCT FROM($0, $1)], joinType=[semi])
            LogicalProject(ENAME=[$1])
              LogicalFilter(condition=[=($7, 10)])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
            LogicalProject(ENAME=[$1])
              LogicalFilter(condition=[=($7, 20)])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
          LogicalProject(ENAME=[$1])
            LogicalFilter(condition=[=($7, 30)])
              LogicalTableScan(table=[[CATALOG, SALES, EMP]]) 

      The number of inputs needs to be greater than 1. 

      Attachments

        Issue Links

          Activity

            People

              jensen Zhen Chen
              jensen Zhen Chen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: