[ 
https://issues.apache.org/jira/browse/CALCITE-7070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17985921#comment-17985921
 ] 

Mihai Budiu commented on CALCITE-7070:
--------------------------------------

The fix looked safe to me, since residue is a conservative approximation, and 
leaving terms in unsimpligied should always be safe.

The assertion looks wrong, since the code that inserts values in the list of 
predicates does not ensure that they do not contain null literals.

> 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)

Reply via email to