[
https://issues.apache.org/jira/browse/PHOENIX-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
alex kamil updated PHOENIX-915:
-------------------------------
Description:
numeric functions ROUND, CEIL, FLOOR return incorrect results for DOUBLE (it
works correctly only for DECIMAL)
>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.
was:
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.
Summary: Numeric functions ROUND, CEIL, FLOOR return incorrect results
for DOUBLE (was: Numeric functions ROUND, CEIL, FLOOR return incorrect results)
> Numeric functions ROUND, CEIL, FLOOR return incorrect results for DOUBLE
> ------------------------------------------------------------------------
>
> 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 for DOUBLE (it
> works correctly only for DECIMAL)
> >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)