[
https://issues.apache.org/jira/browse/DRILL-5595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16060199#comment-16060199
]
Boaz Ben-Zvi commented on DRILL-5595:
-------------------------------------
Drill's support for casting an int into a boolean is not documented, and seems
to come out of matching Postgres' behavior (see DRILL-4674).
However Postgres does not support casting a float into a boolean:
{code}
postgres=# values(cast(cast(0.3 as float) as boolean));
Error(s), warning(s):
42846: cannot cast type double precision to boolean
{code}
And what should the semantics be ? Is the threshold between true and false
around 0.5 :
{code}
0: jdbc:drill:zk=local> select cast(cast(0.4999 as integer) as boolean) from
(values(1));
+---------+
| EXPR$0 |
+---------+
| false |
+---------+
1 row selected (0.144 seconds)
0: jdbc:drill:zk=local> select cast(cast(0.5000 as integer) as boolean) from
(values(1));
+---------+
| EXPR$0 |
+---------+
| true |
+---------+
1 row selected (0.134 seconds)
{code}
> Casting Floating-point types to Boolean types should be supported
> -----------------------------------------------------------------
>
> Key: DRILL-5595
> URL: https://issues.apache.org/jira/browse/DRILL-5595
> Project: Apache Drill
> Issue Type: Bug
> Components: Execution - Data Types, Query Planning & Optimization
> Affects Versions: 1.11.0
> Reporter: Abhishek Girish
> Assignee: Chunhui Shi
>
> Today, only Int and BigInt can be casted to Boolean. Casting Float / Double
> values to Boolean fails:
> {code}
> select cast(1.0 as boolean) from (values(1));
> Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1.0
> select cast(t.a as boolean) from (select cast(1.0 as float) as a from
> (values(1))) t;
> Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1.0
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)