Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
None
-
None
-
None
-
2021-16, 2021-17
Description
Summary
There appears to be a bug with ROUND() on doubles in case statements in conjunction with subqueries. The workaround is to use round(, 3) - or anything but round(,2). Given recent full decimal support there might be a bug or default value that's overriding the round( ,2).
Simplified Reproduction Steps:
create table rounding_table ( a int, b double, c double) engine=columnstore; |
insert into rounding_table values (26805, 1252, -9647); |
insert into rounding_table values (26806, 573, -2804.5); |
 |
SELECT
|
CASE a
|
WHEN 26805 THEN ROUND(c/b, 2) |
WHEN 26806 THEN b |
END wrongNumberOfDecimals,
|
ROUND(c/b, 2) as correctNumberOfDecimals |
FROM (
|
SELECT a, SUM(b) b, SUM(c) c FROM rounding_table
|
GROUP BY a
|
) abc ;
|
Results:
+-----------------------+-------------------------+
|
| wrongNumberOfDecimals | correctNumberOfDecimals |
|
+-----------------------+-------------------------+
|
| 573 | -4.89 | |
| -7.709999999999999 | -7.71 | |
+-----------------------+-------------------------+
|
Expected: -7.71
Actual: -7.709999999999999