[ 
https://issues.apache.org/jira/browse/DRILL-4970?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Hou updated DRILL-4970:
------------------------------
    Description: 
This query returns the wrong result

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from test_table 
where (int_id > -3025 and bigint_id <= -256) or (cast(double_id as bigint) >= 
-255 and double_id <= -5);
+---------+
| EXPR$0  |
+---------+
| 2769    |
+---------+

Without the cast, it returns the correct result:

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from test_table 
where (int_id > -3025 and bigint_id <= -256) or (double_id >= -255 and 
double_id <= -5);
+---------+
| EXPR$0  |
+---------+
| 3020    |
+---------+

By itself, the result is also correct:

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from test_table 
where (cast(double_id as bigint) >= -255 and double_id <= -5);
+---------+
| EXPR$0  |
+---------+
| 251     |
+---------+


  was:
This query returns the wrong result

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
orders_parts_rowgr1 where (int_id > -3025 and bigint_id <= -256) or 
(cast(double_id as bigint) >= -255 and double_id <= -5);
+---------+
| EXPR$0  |
+---------+
| 2769    |
+---------+

Without the cast, it returns the correct result:

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
orders_parts_rowgr1 where (int_id > -3025 and bigint_id <= -256) or (double_id 
>= -255 and double_id <= -5);
+---------+
| EXPR$0  |
+---------+
| 3020    |
+---------+

By itself, the result is also correct:

0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
orders_parts_rowgr1 where (cast(double_id as bigint) >= -255 and double_id <= 
-5);
+---------+
| EXPR$0  |
+---------+
| 251     |
+---------+



> Wrong results when casting double to bigint or int
> --------------------------------------------------
>
>                 Key: DRILL-4970
>                 URL: https://issues.apache.org/jira/browse/DRILL-4970
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Data Types
>    Affects Versions: 1.8.0
>            Reporter: Robert Hou
>         Attachments: test_table
>
>
> This query returns the wrong result
> 0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
> test_table where (int_id > -3025 and bigint_id <= -256) or (cast(double_id as 
> bigint) >= -255 and double_id <= -5);
> +---------+
> | EXPR$0  |
> +---------+
> | 2769    |
> +---------+
> Without the cast, it returns the correct result:
> 0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
> test_table where (int_id > -3025 and bigint_id <= -256) or (double_id >= -255 
> and double_id <= -5);
> +---------+
> | EXPR$0  |
> +---------+
> | 3020    |
> +---------+
> By itself, the result is also correct:
> 0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(*) from 
> test_table where (cast(double_id as bigint) >= -255 and double_id <= -5);
> +---------+
> | EXPR$0  |
> +---------+
> | 251     |
> +---------+



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to