You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2014/08/28 03:45:57 UTC

[jira] [Commented] (PHOENIX-1206) Decimal serialization broken for negative numbers with more than 19 digits of precision

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

Hudson commented on PHOENIX-1206:
---------------------------------

FAILURE: Integrated in Phoenix | Master | Hadoop1 #348 (See [https://builds.apache.org/job/Phoenix-master-hadoop1/348/])
PHOENIX-1206 Decimal serialization broken for negative numbers with more than 19 digits of precision (Kyle Buzsaki) (jamestaylor: rev e8c2664e7705901991114278d182b65c2fb57c00)
* phoenix-core/src/main/java/org/apache/phoenix/util/NumberUtil.java
* phoenix-core/src/test/java/org/apache/phoenix/schema/PDataTypeTest.java
* phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsTest.java
* phoenix-core/src/main/java/org/apache/phoenix/schema/PDataType.java


> Decimal serialization broken for negative numbers with more than 19 digits of precision
> ---------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1206
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1206
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Kyle Buzsaki
>            Assignee: Kyle Buzsaki
>             Fix For: 5.0.0, 4.2, 3.2
>
>         Attachments: PHOENIX-1206.patch
>
>
> Our decimal type is supposed to support 38 digits of precision, but arithmetic with negative numbers at any precision higher than 19 digits produces incorrect results.
> I have reproduced the error below. In the first two (incorrect) queries, the right hand side is 1^-20 (19 zeros, then a 1). In the last two (correct) queries, the right hand side is 1^-19 (18 zeros, then a 1). 
> Here's a reproduction in sqline: 
> {code}
> 0: jdbc:phoenix:localhost> create table demo (dec DECIMAL primary key);
> No rows affected (0.264 seconds)
> 0: jdbc:phoenix:localhost> upsert into demo values(0.5);
> 1 row affected (0.006 seconds)
> 0: jdbc:phoenix:localhost> upsert into demo values(-0.5);
> 1 row affected (0.005 seconds)
> 0: jdbc:phoenix:localhost> select dec, dec + 0.00000000000000000001 from demo;
> +------------+--------------------------------+
> |    DEC     | (DEC + 0.00000000000000000001) |
> +------------+--------------------------------+
> | -0.5       | -0.50000000000000000057        |
> | 0.5        | 0.50000000000000000001         |
> +------------+--------------------------------+
> 2 rows selected (0.03 seconds)
> 0: jdbc:phoenix:localhost> select dec, dec - 0.00000000000000000001 from demo;
> +------------+--------------------------------+
> |    DEC     | (DEC - 0.00000000000000000001) |
> +------------+--------------------------------+
> | -0.5       | -0.49999999999999999999        |
> | 0.5        | 0.49999999999999999999         |
> +------------+--------------------------------+
> 2 rows selected (0.032 seconds)
> 0: jdbc:phoenix:localhost> 
> 0: jdbc:phoenix:localhost> select dec, dec + 0.0000000000000000001 from demo;
> +------------+-------------------------------+
> |    DEC     | (DEC + 0.0000000000000000001) |
> +------------+-------------------------------+
> | -0.5       | -0.4999999999999999999        |
> | 0.5        | 0.5000000000000000001         |
> +------------+-------------------------------+
> 2 rows selected (0.032 seconds)
> 0: jdbc:phoenix:localhost> select dec, dec - 0.0000000000000000001 from demo;
> +------------+-------------------------------+
> |    DEC     | (DEC - 0.0000000000000000001) |
> +------------+-------------------------------+
> | -0.5       | -0.5000000000000000001        |
> | 0.5        | 0.4999999999999999999         |
> +------------+-------------------------------+
> 2 rows selected (0.029 seconds)
> 0: jdbc:phoenix:localhost> 
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)