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

RelOptUtil.splitJoinCondition() could not split condition with case after applying FilterReduceExpressionsRule

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.16.0
    • core
    • None

    Description

      Query

      select * from emp a emp b where coalesce(a.mgr, -1) = coalesce(b.mgr, -1)
      

      has logical plan

      LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$9], ENAME0=[$10], JOB0=[$11], MGR0=[$12], HIREDATE0=[$13], SAL0=[$14], COMM0=[$15], DEPTNO0=[$16], SLACKER0=[$17])
        LogicalFilter(condition=[=(CASE(IS NOT NULL($3), $3, -1), CASE(IS NOT NULL($12), $12, -1))])
          LogicalJoin(condition=[true], joinType=[inner])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      After applying FilterReduceExpressionsRule condition in filter is changed to

      CASE(IS NOT NULL($12), CASE(IS NOT NULL($3), =($3, $12), =(-1, $12)), CASE(IS NOT NULL($3), =($3, -1), CAST(true):BOOLEAN))
      

      When this condition is passed into RelOptUtil.splitJoinCondition() method, leftJoinKeys and rightJoinKeys lists are left empty and passed condition is returned.

      Note: RelOptUtil.splitJoinCondition() works correctly for the initial condition without applying FilterReduceExpressionsRule.

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            volodymyr Vova Vysotskyi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: