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

JoinDeriveIsNotNullFilterRule incorrectly handles COALESCE in join condition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.34.0
    • 1.35.0
    • None

    Description

      Consider query

      select t1.deptno from empnullables t1 inner join
      empnullables t2 on coalesce(t1.ename, t2.ename) = 'abc' 

      When JoinDeriveIsNotNullFilterRule is applied to it, it is incorrectly transformed to query plan

      LogicalProject(DEPTNO=[$7])
       LogicalJoin(condition=[=(CASE(IS NOT NULL($1), $1, $10), 'abc')], joinType=[inner])
         LogicalFilter(condition=[IS NOT NULL($1)])
           LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
         LogicalFilter(condition=[IS NOT NULL($1)])
           LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]]) 

      It is not valid to deduce that join keys from the both sides cannot have null values. All that we can deduce from the join condition, is that they cannot be null in the same time.

      Attachments

        Issue Links

          Activity

            People

              lchistov1987 Leonid Chistov
              lchistov1987 Leonid Chistov
              Votes:
              0 Vote for this issue
              Watchers:
              5 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 - 1h
                  1h