You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Zongwen Li (Jira)" <ji...@apache.org> on 2021/10/29 08:00:00 UTC

[jira] [Comment Edited] (FLINK-24691) FLINK SQL SUM() causes a precision error

    [ https://issues.apache.org/jira/browse/FLINK-24691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17435830#comment-17435830 ] 

Zongwen Li edited comment on FLINK-24691 at 10/29/21, 7:59 AM:
---------------------------------------------------------------

[~matriv] org.apache.flink.table.types.logical.utils.LogicalTypeMerging#adjustPrecisionScale method was added in 1.14. Because sum() generates max precision(38) by default, it leads to special circumstances, which reduces the scale by 1.


was (Author: ashulin):
[~matriv] org.apache.flink.table.types.logical.utils.LogicalTypeMerging#adjustPrecisionScale method was added in 1.14. Because sum() generates decimal(38,8) by default, it leads to special circumstances, which reduces the scale by 1.

> FLINK SQL SUM() causes a precision error
> ----------------------------------------
>
>                 Key: FLINK-24691
>                 URL: https://issues.apache.org/jira/browse/FLINK-24691
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Runtime
>    Affects Versions: 1.14.0
>            Reporter: Zongwen Li
>            Assignee: Marios Trivyzas
>            Priority: Major
>         Attachments: image-2021-10-29-15-49-14-419.png
>
>
> code: 
> {code:java}
> tableEnv.executeSql("select sum(cast( 1.03520274 as decimal(32, 8))) as num ").print();
> {code}
> expected:
> 1.03520274
> actual:
> 1.03520270
>  
> This function is normal in version 1.13.x.
> I found the code that caused the inconsistency:
> org.apache.flink.table.types.logical.utils.LogicalTypeMerging#adjustPrecisionScale method was added in 1.14. Because sum() generates max precision(38) by default, it leads to special circumstances, which reduces the scale by 1.
>   !image-2021-10-29-15-49-14-419.png!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)