Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-24691

FLINK SQL SUM() causes a precision error

    XMLWordPrintableJSON

Details

    • This changes the result of a decimal SUM() between 1.14.0 and 1.14.1. It restores the behavior of 1.13 to be consistent with Hive/Spark.

    Description

      code: 

      tableEnv.executeSql("select sum(cast( 1.03520274 as decimal(32, 8))) as num ").print();
      

      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.

       

      Attachments

        Issue Links

          Activity

            People

              matriv Marios Trivyzas
              Ashulin Zongwen Li
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: