You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Victoria Markman (JIRA)" <ji...@apache.org> on 2015/02/05 07:21:34 UTC

[jira] [Commented] (DRILL-2015) Casting numeric value that does not fit in integer data type produces incorrect result

    [ https://issues.apache.org/jira/browse/DRILL-2015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14306722#comment-14306722 ] 

Victoria Markman commented on DRILL-2015:
-----------------------------------------

Example with the simple function:

{code}
0: jdbc:drill:schema=dfs> select * from tab;
+------------+
|     a1     |
+------------+
| -3477884857818808320 |
| 0          |
| 0          |
| 4465148082249531392 |
| 4465148082249531392 |
+------------+
5 rows selected (0.057 seconds)

0: jdbc:drill:schema=dfs> select round(a1/13) from tab;
+------------+
|   EXPR$0   |
+------------+
| -2147483648 |
| 0          |
| 0          |
| 2147483647 |
| 2147483647 |
+------------+
{code}

> Casting numeric value that does not fit in integer data type produces incorrect result
> --------------------------------------------------------------------------------------
>
>                 Key: DRILL-2015
>                 URL: https://issues.apache.org/jira/browse/DRILL-2015
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Execution - Data Types
>    Affects Versions: 0.8.0
>            Reporter: Victoria Markman
>            Assignee: Daniel Barclay (Drill/MapR)
>             Fix For: Future
>
>
> t1.json
> {code}
> { "a1": 1 ,    "b1" : 1}
> { "a1": 2 ,    "b1" : 1}
> { "a1": 2 ,    "b1" : 2}
> { "a1": 3 ,    "b1" : 2}
> { "a1": 5000147483647 , "b1" : 3}
> {code}
> We should throw an error, this is technically data corruption.
> {code}
> 0: jdbc:drill:schema=dfs> select cast(a1 as integer) from `t1.json`;
> +------------+
> |   EXPR$0   |
> +------------+
> | 1          |
> | 2          |
> | 2          |
> | 3          |
> | 805551103  |
> +------------+
> 5 rows selected (0.074 seconds)
> {code}
> {code}
> 0: jdbc:drill:schema=dfs> select cast(2147483648 as integer) from `t1.json`;
> +------------+
> |   EXPR$0   |
> +------------+
> | -2147483648 |
> | -2147483648 |
> | -2147483648 |
> | -2147483648 |
> | -2147483648 |
> +------------+
> 5 rows selected (0.076 seconds)
> {code}



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