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

Validator infers incorrect type for "IS NOT DISTINCT FROM"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Validator infers incorrect type for "IS NOT DISTINCT FROM". I got the following output from a test:

      [INFO] Running org.apache.calcite.test.fuzzer.RexProgramFuzzyTest
      2019-11-13 13:30:16,459 [pool-1-thread-3] INFO  - Using seed 44 for rex fuzzing
      2019-11-13 13:30:19,869 [pool-1-thread-3] INFO  - Rex fuzzing results: number of cases tested=2000, failed cases=0, duplicate failures=0, fuzz rate=586 per second
      Shrinked to 36669 chars, time remaining 19997
      Shrinked to 9704 chars, time remaining 19996
      Shrinked to 9631 chars, time remaining 19993
      Shrinked to 9287 chars, time remaining 19992
      Shrinked to 7058 chars, time remaining 19989
      Shrinked to 6507 chars, time remaining 19986
      Shrinked to 5317 chars, time remaining 19985
      Shrinked to 5191 chars, time remaining 19985
      Shrinked to 4990 chars, time remaining 19984
      Shrinked to 4844 chars, time remaining 19984
      Shrinked to 3877 chars, time remaining 19981
      Shrinked to 3628 chars, time remaining 19981
      Shrinked to 275 chars, time remaining 19980
      Shrinked to 258 chars, time remaining 19980
      Shrinked to 239 chars, time remaining 19980
      Shrinked to 188 chars, time remaining 19979
      2019-11-13 13:30:20,616 [pool-1-thread-1] INFO  - Rex fuzzing results: number of cases tested=406, failed cases=1, duplicate failures=0, fuzz rate=100 per second
      2019-11-13 13:30:20,617 [pool-1-thread-1] INFO  - Randomized test identified a potential defect. Feel free to fix that issue
      java.lang.IllegalStateException: Unable to simplify unknownAsFalse<(IS NOT DISTINCT FROM(>(+(CAST(0):INTEGER), +(0)), true), true)
      lt(isNotDistinctFrom(gt(unaryPlus(abstractCast(literal(0), tInt(true))), unaryPlus(literal(0))), trueLiteral), trueLiteral)
      	at org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAs(RexProgramFuzzyTest.java:228)
      	at org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAsAndShrink(RexProgramFuzzyTest.java:209)
      	at org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAs(RexProgramFuzzyTest.java:172)
      	at org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.generateRexAndCheckTrueFalse(RexProgramFuzzyTest.java:462)
      	Suppressed: org.apache.calcite.test.fuzzer.RexProgramFuzzyTest$1: seed -104518976443406885
      Caused by: java.lang.AssertionError
      	at org.apache.calcite.rex.RexSimplify.validateStrongPolicy(RexSimplify.java:843)
      	at org.apache.calcite.rex.RexSimplify.simplifyIs2(RexSimplify.java:682)
      	at org.apache.calcite.rex.RexSimplify.simplifyIs(RexSimplify.java:653)
      	at org.apache.calcite.rex.RexSimplify.simplify(RexSimplify.java:281)
      

      I believe that it means that a particular call to IS NOT DISTINCT FROM has a not-null return and has nullable arguments and this contradict's the Strong.ANY policy. I suspect that the policy for that operator should not be Strong.ANY.

      Discovered by the validateStrongPolicy method added in CALCITE-3457.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: