[
https://issues.apache.org/jira/browse/CALCITE-2929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16795204#comment-16795204
]
Zoltan Haindrich commented on CALCITE-2929:
-------------------------------------------
If I count it correctly there are 4 issues here:
* simplification should not react right away on a non-nullable argument of an
IS NULL ; because it could be cast() IS NULL
* CAST shouldn't be considered "Strong"; as it may hide away errors
* RexImpTable.OptimizedCast should use NullPolicy.NONE
* RexProgram also considers cast as
[strong|https://github.com/apache/calcite/blob/ffca956be03a99cd11e440d652b09674aaa727e6/core/src/main/java/org/apache/calcite/rex/RexProgram.java#L490]
* after this there are some "KNOWN_NON_NULL_METHODS" which contains all the
valueOf methods - because these methods are effectively executing casts; the
fix would mean to "remove" this
[KNOWN_NON_NULL_METHODS|https://github.com/apache/calcite/blob/ffca956be03a99cd11e440d652b09674aaa727e6/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java#L56]
I right now feel that it would be probably better to split this into 2:
* fix the regression after CALCITE-2469 by including only the first 2 fixes
(Strong + better simplification)
* RexProgram/RexToLix/OptimizeShuttle related fixes
> Simplification of IS NULL checks are incorrectly assuming that CAST-s are
> possible
> ----------------------------------------------------------------------------------
>
> Key: CALCITE-2929
> URL: https://issues.apache.org/jira/browse/CALCITE-2929
> Project: Calcite
> Issue Type: Bug
> Reporter: Zoltan Haindrich
> Assignee: Zoltan Haindrich
> Priority: Major
>
> Example:
> {code}
> with ax(s) as (values ('xxx'),(cast(null as character varying)))
> select cast(s as int) IS NULL from ax;
> {code}
> returns a result set; which evaluates
> however 'xxx' is not a valid integer; so an error should be recieved instead
> Another class of almost the same issue:
> {code}
> select cast('xxx' as int) IS NULL;
> {code}
> is also problematic; in that case the not nullability is deduced from the
> fact that the literal's type is not nullable
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)