alex kamil created PHOENIX-915:
----------------------------------

             Summary: Numeric functions ROUND, CEIL, FLOOR return incorrect 
results
                 Key: PHOENIX-915
                 URL: https://issues.apache.org/jira/browse/PHOENIX-915
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 3.0.0, 4.0.0
            Reporter: alex kamil
             Fix For: 3.0.0


numeric functions ROUND, CEIL, FLOOR return incorrect results.

>CREATE TABLE myproducts (id BIGINT NOT NULL PRIMARY KEY, price DOUBLE);
> UPSERT INTO myproducts (id,price) values (1,22.33);
>SELECT id, price, ROUND(price) as roundedPrice from myproducts;
+------------+------------+--------------+
|     ID     |   PRICE    | ROUNDEDPRICE |
+------------+------------+--------------+
| 1          | 22.33      | 1.0          |


(ROUND returns 1.0 instead of 22)

SELECT id, price, ROUND(price,1) as roundedPrice from myproducts;
+------------+------------+--------------+
|     ID     |   PRICE    | ROUNDEDPRICE |
+------------+------------+--------------+
| 1          | 22.33      | 0.5          |

(ROUND returns 0.5 instead of 22.3)

>SELECT id, price, CEIL(price) as roundedPrice from myproducts;
+------------+------------+--------------+
|     ID     |   PRICE    | ROUNDEDPRICE |
+------------+------------+--------------+
| 1          | 22.33      | 1.0          |

(CEIL returns 1.0 instead of 23)

>SELECT id, price, FLOOR(price) as roundedPrice from myproducts;
+------------+------------+--------------+
|     ID     |   PRICE    | ROUNDEDPRICE |
+------------+------------+--------------+
| 1          | 22.33      | 0.0          |

(FLOOR returns 0.0 instead of 22)

etc.




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

Reply via email to