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

   ### 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
   
   1.1.3 & 1.2.1
   
   ### What's Wrong?
   
   **case 1:**
   
   `  with vb1 as(
           select '7.1' as col
           union all
           select '8.123456' as col
       )
       select 'decimal-原始未截断' as type,cast(col as decimal(25,6)) col from vb1
       union all
       select 'decimal-截断保留3位小数' as type,truncate (cast(col as 
decimal(25,6)),3)  col from vb1
       union all
       select 'decimal-截断保留5位小数' as type,truncate (cast(col as 
decimal(25,6)),5)  col from vb1
       union all
       select 'decimal-截断保留7位小数' as type,truncate (cast(col as 
decimal(25,6)),7)  col from vb1`
   the 1.1.3 and 1.2.1 result is :
   
![企业微信截图_16762747658858](https://user-images.githubusercontent.com/9799728/218402948-f473785b-2eef-4889-9452-f12b521ccbdf.png)
   
   **case2:**
   
   `with vb1 as(
           select '7.1' as col
           union all
           select '8.123456' as col
       )
       select 'double-原始未截断' as type,cast(col as double) col from vb1
       union all
       select 'double-截断保留3位小数' as type,truncate (cast(col as double),3)  col 
from vb1
       union all
       select 'double-截断保留5位小数' as type,truncate (cast(col as double),5)  col 
from vb1
       union all
       -- ******结果不符合预期:8.1234559*****
       select 'double-截断保留7位小数' as type,truncate (cast(col as double),7)  col 
from vb1`
   the 1.1.3 result is:
   
![企业微信截图_16762747831620](https://user-images.githubusercontent.com/9799728/218403209-b1f14557-3bc1-428a-a5c1-c73a2e7bd650.png)
   the 1.2.1 result is:
   
![企业微信截图_16762747971704](https://user-images.githubusercontent.com/9799728/218403274-5e45d8f0-ffb8-4c80-a252-1e18b7699476.png)
   
   **case3:**
   
   `with vb1 as(
           select cast('8.12' as decimal(20, 2)) as 
decimal_20_2,cast('9.123456' as decimal(20, 6)) as decimal_20_6
           union all
           select cast('8.45' as decimal(20, 2)) as 
decimal_20_2,cast('9.654321' as decimal(20, 6)) as decimal_20_6
   )
   select '原始数据-未做类型和精度转换' as type
   , decimal_20_2
   ,decimal_20_6
   from vb1
   union all
   select 'decimal-扩大类型' as type
   ,cast(decimal_20_2 as decimal(25,6)) decimal_20_2
   ,cast(decimal_20_6 as decimal(25,6)) decimal_20_6
   from vb1
   union all
   select 'decimal-round四舍五入保留两位小数' as type
   -- *** 扩大精度后四舍五入结果错误8.12结果为8.119999999
   ,round(cast(decimal_20_2 as decimal(25,6)),2) decimal_20_2
   ,round(cast(decimal_20_6 as decimal(25,6)),2) decimal_20_6
   from vb1`
   
   the 1.1.3 and 1.2.1 result is:
   
![企业微信截图_16762748752795](https://user-images.githubusercontent.com/9799728/218403469-e0fca716-b38f-4c13-8f6d-5b6d5e4161d1.png)
   
   
   
   ### What You Expected?
   
   return the correct result
   
   ### 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-unsubscr...@doris.apache.org.apache.org

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


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

Reply via email to