You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2023/06/15 06:31:00 UTC
[jira] [Resolved] (CALCITE-4679) Search/sarg simplification leaves is not null(literal) unsimplified
[ https://issues.apache.org/jira/browse/CALCITE-4679?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
xiong duan resolved CALCITE-4679.
---------------------------------
Resolution: Resolved
> 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
> Affects Versions: 1.34.0
> Reporter: Vladimir Sitnikov
> Assignee: Runkang He
> Priority: Major
> Fix For: 1.35.0
>
>
> 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)