You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Vladimir Sitnikov (Jira)" <ji...@apache.org> on 2021/07/06 10:21:00 UTC
[jira] [Created] (CALCITE-4679) Search/sarg simplification leaves
is not null(literal) unsimplified
Vladimir Sitnikov created CALCITE-4679:
------------------------------------------
Summary: 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
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.3.4#803005)