[
https://issues.apache.org/jira/browse/CALCITE-7070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17985924#comment-17985924
]
Julian Hyde commented on CALCITE-7070:
--------------------------------------
In Rex-land I don't believe that we ever create a comparison such as "x <
NULL". That assertion (added in CALCITE-6552) was a statement of my belief.
The tests for {{RexSimplify}} are the definitive statement of what we do and do
not support. So if you are increasing the envelope you should be adding tests
(or at least checking whether that tests exist). See
[RexProgramTest.testSimplify|https://github.com/apache/calcite/blob/cf91ec8f36e1f7cf9656e2f794d8f78a2b43d88c/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java#L849].
> FILTER_REDUCE_EXPRESSIONS crashes on expression BETWEEN ( NULL) AND X
> ---------------------------------------------------------------------
>
> Key: CALCITE-7070
> URL: https://issues.apache.org/jira/browse/CALCITE-7070
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.40.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
> Fix For: 1.41.0
>
>
> The following test inserted in RelOptRulesTest crashes:
> {code}
> final String sql = "SELECT + 54 FROM emp WHERE NOT CAST ( CAST(empno AS
> DOUBLE) AS INTEGER ) NOT BETWEEN ( NULL ) AND 89";
> sql(sql)
> .withRule(CoreRules.FILTER_REDUCE_EXPRESSIONS)
> .check();
> {code}
> stack trace:
> {code}
> java.lang.AssertionError: value must not be null in null:INTEGER
> at org.apache.calcite.rex.RexSimplify.residue(RexSimplify.java:1968)
> at
> org.apache.calcite.rex.RexSimplify.simplifyUsingPredicates(RexSimplify.java:1909)
> at
> org.apache.calcite.rex.RexSimplify.simplifyComparison(RexSimplify.java:655)
> at
> org.apache.calcite.rex.RexSimplify.simplifyComparison(RexSimplify.java:517)
> at org.apache.calcite.rex.RexSimplify.simplify(RexSimplify.java:313)
> at
> org.apache.calcite.rex.RexSimplify.simplifyAndTerms(RexSimplify.java:694)
> at org.apache.calcite.rex.RexSimplify.simplifyAnd(RexSimplify.java:1559)
> at org.apache.calcite.rex.RexSimplify.simplify(RexSimplify.java:282)
> at org.apache.calcite.rex.RexSimplify.simplifyNot(RexSimplify.java:761)
> at org.apache.calcite.rex.RexSimplify.simplify(RexSimplify.java:286)
> at
> org.apache.calcite.rex.RexSimplify.simplifyUnknownAs(RexSimplify.java:251)
> at
> org.apache.calcite.rex.RexSimplify.simplifyPreservingType(RexSimplify.java:190)
> at
> org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions(ReduceExpressionsRule.java:722)
> at
> org.apache.calcite.rel.rules.ReduceExpressionsRule$FilterReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:159)
> {code}
> This test is modified from SqlLogicTest.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)