Description
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:
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
Test:
checkSimplify(
rexBuilder.makeCall(
SqlStdOperatorTable.SEARCH,
literal(BigDecimal.ZERO),
rexBuilder.makeSearchArgumentLiteral(
Sarg.of(RexUnknownAs.UNKNOWN, ImmutableRangeSet.of(Range.<BigDecimal>all())),
tInt())),
"true"
);
—
fuzzer:
@Test void singleFuzzyTest() { Random r = new Random(); r.setSeed(-8889103384303613092L); RexFuzzer fuzzer = new RexFuzzer(rexBuilder, typeFactory); generateRexAndCheckTrueFalse(fuzzer, r); }
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)
Attachments
Issue Links
- is duplicated by
-
CALCITE-5759 'SEARCH(1, Sarg[IS NOT NULL])' should be simplified to 'TRUE'
- Closed