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

PruneEmptyRules#JOIN_RIGHT_INSTANCE wrong behavior for JoinRelType.ANTI

    XMLWordPrintableJSON

Details

    Description

      The rule PruneEmptyRules#JOIN_RIGHT_INSTANCE "converts a Join to empty if its right child is empty", e.g.

      Join(Scan(Emp), Empty, INNER) becomes Empty
      

      The rule verifies that the join type cannot be LEFT / FULL, and the transformation is not performed in those cases:

      if (join.getJoinType().generatesNullsOnRight()) { // i.e. JoinType == LEFT ||   JoinType == FULL
        // "select * from emp left join dept" is not necessarily empty if dept is empty
        return;
      }
      

      However in case of ANTI, it performs the transformation:

      Join(Scan(Emp), Empty, ANTI) becomes Empty
      

      but this transformation is wrong for anti-join, in this case the actual result should be:

      Join(Scan(Emp), Empty, ANTI) becomes Scan(Emp)
      

      in case of anti equi-join (in case of non-equi, no transformation shall be made).

      Attachments

        Issue Links

          Activity

            People

              rubenql Ruben Q L
              rubenql Ruben Q L
              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 - 20m
                  20m