[
https://issues.apache.org/jira/browse/CALCITE-2929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16795796#comment-16795796
]
Zoltan Haindrich commented on CALCITE-2929:
-------------------------------------------
[~danny0405]: for nullability yes; the assumption is correct - however the
"error" is not coming out...
I think {{cast('xxx' as integer)}} should end with an exception...but if I
write {{cast('xxx' as integer}} is null}} then it's just "false" is this
behaviour correct?
Lets assume for a minute that:
* {{cast('xxx' as integer) is null}} is a valid expression
* it evaluates to {{false} (as it is now)
then I would be inclined to ask: What is the value of {{cast('xxx' as
integer)}} - apparently it's not null; so it should be some (existing) integer
value...which one is it?
The sql standard advises to raise error in case the string could not be
interpreted in the target type; it could be found under 9075-2:2011 around
"<cast specification>:
{code}
8) If TD is exact numeric, then
Case:
[...]
b) If SD is character string, then SV is replaced by SV with any leading or
trailing <space>s removed.
Case:
i) If SV does not comprise a <signed numeric literal> as defined by the
rules for <literal> in
Subclause 5.3, “<literal>”, then an exception condition is raised: data
exception — invalid
character value for cast.
[...]
{code}
so, I think CAST may not be considered Strong
> 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)