[ https://issues.apache.org/jira/browse/CALCITE-4679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17731146#comment-17731146 ]
Runkang He edited comment on CALCITE-4679 at 6/10/23 2:00 AM: -------------------------------------------------------------- [~vladimirsitnikov] This is the same issue as [CALCITE-5759|https://issues.apache.org/jira/browse/CALCITE-5759], I would like to fix it. was (Author: JIRAUSER280488): [~vladimirsitnikov]This is the same issue as [CALCITE-5759|https://issues.apache.org/jira/browse/CALCITE-5759], I would like to fix it. > Search/sarg simplification leaves is not null(literal) unsimplified > ------------------------------------------------------------------- > > Key: CALCITE-4679 > URL: https://issues.apache.org/jira/browse/CALCITE-4679 > Project: Calcite > Issue Type: Improvement > Components: core > Reporter: Vladimir Sitnikov > Priority: Major > > Case: {{SEARCH(100500, Sarg[=])}} (Sarg[=] is "all values match, unknown as > unknown"). > While the issue does not look severe, it results in rex fuzzer false > positives, so it might mask true bugs. > Expected: {{true}} > Actual: > {noformat} > unknown as unknown: OR(IS NOT NULL(0), null) > unknown as false: IS NOT NULL(0) > unknown as true: true <-- finally got the right answer > {noformat} > Test: > {code:java} > checkSimplify( > rexBuilder.makeCall( > SqlStdOperatorTable.SEARCH, > literal(BigDecimal.ZERO), > rexBuilder.makeSearchArgumentLiteral( > Sarg.of(RexUnknownAs.UNKNOWN, > ImmutableRangeSet.of(Range.<BigDecimal>all())), > tInt())), > "true" > ); > {code} > --- > fuzzer: > {code:java} > @Test void singleFuzzyTest() { > Random r = new Random(); > r.setSeed(-8889103384303613092L); > RexFuzzer fuzzer = new RexFuzzer(rexBuilder, typeFactory); > generateRexAndCheckTrueFalse(fuzzer, r); > }{code} > {noformat} > AssertionFailedError: SEARCH(100500, Sarg[=]) > rexBuilder.makeCall(SqlStdOperatorTable.SEARCH, literal(100500), > literal(Sarg[=])) isAlwaysTrue, so it should simplify to TRUE unknownAsFalse > ==> expected: <true> but was: <IS NOT NULL(100500)> > at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55) > at > org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:69) > at > org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:188) > at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1146) > at > org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAs(RexProgramFuzzyTest.java:251) > at > org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAsAndShrink(RexProgramFuzzyTest.java:202) > at > org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.checkUnknownAs(RexProgramFuzzyTest.java:165) > at > org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.generateRexAndCheckTrueFalse(RexProgramFuzzyTest.java:454) > at > org.apache.calcite.test.fuzzer.RexProgramFuzzyTest.singleFuzzyTest(RexProgramFuzzyTest.java:463) > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)