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

[jira] [Resolved] (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:all-tabpanel ]

James Taylor resolved PHOENIX-1206.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 3.2
                   4.2
                   5.0.0

Thanks for the excellent work, [~kbuzsaki].

> 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)