[
https://issues.apache.org/jira/browse/CALCITE-4782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17759400#comment-17759400
]
Julian Hyde commented on CALCITE-4782:
--------------------------------------
This case is the reverse of CALCITE-5662, CAST(BOOLEAN AS numeric). The
solution should be the same: disallow in the default conformance, allow if
{{SqlConformance.allowLenientCoercion}} is true.
I have changed the summary from ""Casting from a numeric type to boolean is
always false" to "Allow CAST(numeric AS BOOLEAN) (if enabled by conformance)".
When fixing, please specify exactly which numeric types can be converted to
boolean (hopefully all or none), and which numeric values map to true. (As
[~nobigo] pointed out in CALCITE-4777, different database have different
behaviors.)
> Casting from a numeric type to boolean is always false
> ------------------------------------------------------
>
> Key: CALCITE-4782
> URL: https://issues.apache.org/jira/browse/CALCITE-4782
> Project: Calcite
> Issue Type: Bug
> Reporter: xuyang
> Priority: Major
>
> SQL:
> {code:java}
> // code placeholder
> select * from xxx where cast(n as boolean){code}
> In calcite, casting a non-zero number to boolean is always false, which is
> different with other databases. The other databases shows that casting zero
> to boolean is false and casting non-zero value to boolean is true.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)