You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "yunaisheng (via GitHub)" <gi...@apache.org> on 2023/04/20 09:56:23 UTC

[GitHub] [doris] yunaisheng opened a new issue, #18861: [Bug] Doris round函数对整数为偶数,小数为0.5的数字四舍五入计算准确度异常

yunaisheng opened a new issue, #18861:
URL: https://github.com/apache/doris/issues/18861

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Version
   
   doris 1.2.2 release
   doris 2.0.0
   
   ### What's Wrong?
   
   建表语句
   CREATE TABLE `round_test` (
     `id` VARCHAR(100) NULL,
     `f1` FLOAT NULL,
     `f2` DOUBLE NULL,
     `f3` DECIMAL(9, 1) NULL,
     `f4` DECIMALV3(9, 1) NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`id`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`id`) BUCKETS 3
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "in_memory" = "false",
   "storage_format" = "V2",
   "disable_auto_compaction" = "false"
   );
   插入数据
   INSERT INTO round_test VALUES('1',1.5,1.5,1.5,1.5),('2',2.5,2.5,2.5,2.5),('3',13.5,13.5,13.5,13.5),('4',14.5,14.5,14.5,14.5);
   查询数据
   SELECT id,f1 f1_float,ROUND(f1),f2 f2_double,ROUND(f2),f3 f3_decimal,ROUND(f3),f4 f4_decimalv3,ROUND(f4) FROM round_test;
   查询结果
   在FLOAT,DOUBLE,DECIMAL类型,**当整数位为偶数时,小数位为0.5的情况下,使用ROUND函数四舍五入会向下舍掉**,在整数位为奇数时正常;DECIMALV3类型正常;
   `+----+----------+-------------+-----------+-------------+------------+-------------+--------------+-------------+
   | id | f1_float | round(`f1`) | f2_double | round(`f2`) | f3_decimal | round(`f3`) | f4_decimalv3 | round(`f4`) |
   +----+----------+-------------+-----------+-------------+------------+-------------+--------------+-------------+
   | 1  |      1.5 |           2 |       1.5 |           2 | 1.5        |           2 | 1.5          | 2           |
   | 2  |      2.5 |           2 |       2.5 |           2 | 2.5        |           2 | 2.5          | 3           |
   | 3  |     13.5 |          14 |      13.5 |          14 | 13.5       |          14 | 13.5         | 14          |
   | 4  |     14.5 |          14 |      14.5 |          14 | 14.5       |          14 | 14.5         | 15          |
   +----+----------+-------------+-----------+-------------+------------+-------------+--------------+-------------+`
   ![a2b68a2033dc9e50b89e5f9de513c06f](https://user-images.githubusercontent.com/20136048/233329404-0535a54c-2c24-48b2-a093-5235b5fb3856.png)
   Doris旧版本是正常的
   https://doris.apache.org/zh-CN/docs/dev/sql-manual/sql-functions/math-functions/round/
   ![b114fa7b915831781bc80a7666f06167](https://user-images.githubusercontent.com/20136048/233331096-1517ffb3-2f03-4b57-b111-b51ec6bd2e78.png)
   
   
   
   
   
   ### What You Expected?
   
   在1.2.2和后续新版本能够保持对float、double、decimal进行round运算准确性的兼容
   
   ### How to Reproduce?
   
   _No response_
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] yunaisheng closed issue #18861: [Bug] Doris round函数对整数为偶数,小数为0.5的数字四舍五入计算准确度异常

Posted by "yunaisheng (via GitHub)" <gi...@apache.org>.
yunaisheng closed issue #18861: [Bug] Doris round函数对整数为偶数,小数为0.5的数字四舍五入计算准确度异常
URL: https://github.com/apache/doris/issues/18861


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] yunaisheng closed issue #18861: [Bug] Doris round函数对小数修约规则四舍五入计算准确度与旧版本不兼容问题

Posted by "yunaisheng (via GitHub)" <gi...@apache.org>.
yunaisheng closed issue #18861: [Bug] Doris round函数对小数修约规则四舍五入计算准确度与旧版本不兼容问题
URL: https://github.com/apache/doris/issues/18861


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] HappenLee commented on issue #18861: [Bug] Doris round函数对整数为偶数,小数为0.5的数字四舍五入计算准确度异常

Posted by "HappenLee (via GitHub)" <gi...@apache.org>.
HappenLee commented on issue #18861:
URL: https://github.com/apache/doris/issues/18861#issuecomment-1517509793

   The behavior doris in float and double same as `mysql` and `postgresql`, it not a bug. The decimal bug has been fixed in master version


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] yunaisheng commented on issue #18861: [Bug] Doris round函数对整数为偶数,小数为0.5的数字四舍五入计算准确度异常

Posted by "yunaisheng (via GitHub)" <gi...@apache.org>.
yunaisheng commented on issue #18861:
URL: https://github.com/apache/doris/issues/18861#issuecomment-1518913050

   > 
   
   Thanks for your reply, can I understand that this Round behavior was not consistent with Mysql before the handling of float and double in doris lower version and older documents, which is also a bug, float and double handling was fixed after version 1.2.1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org