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

Infer IS NOT NULL, and project predicates

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.11.0
    • Component/s: None
    • Labels:
      None

      Description

      RexImplicationChecker makes some mistakes when OR is on the left-hand size or AND is on the right-hand side. The following 3 tests should all succeed, but all currently give the wrong result. I intend to check in the tests with my fix for CALCITE-1483 (coming soon, currently in my branch https://github.com/julianhyde/calcite/tree/1483-not-in-not-null).

          // "s is not null or i = 5" does not imply "s is not null"
          f.checkNotImplies(f.or(sIsNotNull, iEq5), sIsNotNull);
      
          // "s is not null" implies "s is not null or i = 5"
          f.checkImplies(sIsNotNull, f.or(sIsNotNull, iEq5));
      
          // "s is not null" implies "i = 5 or s is not null"
          f.checkImplies(sIsNotNull, f.or(iEq5, sIsNotNull));
      

      Amogh Margoor, Can you comment on these?

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/dccbb55a.

        The issues were concerning deducing x IS NOT NULL; we could not even deduce x IS NOT NULL from x IS NOT NULL! Now we can deduce x IS NOT NULL from x > 5, among other things.

        This change also makes improvements to RelMdPredicates; if you have a predicate x > y and project away y, the result of the project still has x IS NOT NULL. (Unless x's type is declared NOT NULL, in which case the predicate would be superfluous.)

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/dccbb55a . The issues were concerning deducing x IS NOT NULL ; we could not even deduce x IS NOT NULL from x IS NOT NULL ! Now we can deduce x IS NOT NULL from x > 5 , among other things. This change also makes improvements to RelMdPredicates ; if you have a predicate x > y and project away y , the result of the project still has x IS NOT NULL . (Unless x 's type is declared NOT NULL , in which case the predicate would be superfluous.)
        Hide
        amargoor Amogh Margoor added a comment -

        Julian Hyde Yes, It didn't handle `IS NOT NULL` cases well. I took a look at your fix: http://git-wip-us.apache.org/repos/asf/calcite/commit/dccbb55a and that looks good to me.

        Show
        amargoor Amogh Margoor added a comment - Julian Hyde Yes, It didn't handle `IS NOT NULL` cases well. I took a look at your fix: http://git-wip-us.apache.org/repos/asf/calcite/commit/dccbb55a and that looks good to me.
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.11.0 (2017-01-11).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.11.0 (2017-01-11).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development