[ https://issues.apache.org/jira/browse/DRILL-4970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16068475#comment-16068475 ]
ASF GitHub Bot commented on DRILL-4970: --------------------------------------- GitHub user vvysotskyi opened a pull request: https://github.com/apache/drill/pull/863 DRILL-4970: Prevent changing the negative value of input holder for cast functions Problem description in [DRILL-4970](https://issues.apache.org/jira/browse/DRILL-4970) You can merge this pull request into a Git repository by running: $ git pull https://github.com/vvysotskyi/drill DRILL-4970 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/drill/pull/863.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #863 ---- commit 4b95f11cec99ba339180940ed936bc8e86f8a263 Author: Volodymyr Vysotskyi <vvo...@gmail.com> Date: 2017-06-29T15:28:05Z DRILL-4970: Prevent changing the negative value of input holder for cast functions ---- > 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 > Assignee: Volodymyr Vysotskyi > Attachments: test_table > > > This query returns the wrong result > {code:sql} > 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 | > +---------+ > {code} > Without the cast, it returns the correct result: > {code:sql} > 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 | > +---------+ > {code} > By itself, the result is also correct: > {code:sql} > 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 | > +---------+ > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)