Yuming Wang created SPARK-24362:
-----------------------------------

             Summary: SUM function precision issue
                 Key: SPARK-24362
                 URL: https://issues.apache.org/jira/browse/SPARK-24362
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 2.3.0
            Reporter: Yuming Wang


 

How to reproduce:

 
{noformat}
bin/spark-shell --conf spark.sql.autoBroadcastJoinThreshold=-1


scala> val df = spark.range(6).toDF("c1")

df: org.apache.spark.sql.DataFrame = [c1: bigint]



scala> df.join(df, "c1").selectExpr("sum(cast(9.99 as double))").show()

+-------------------------+

|sum(CAST(9.99 AS DOUBLE))|

+-------------------------+

|       59.940000000000005|

+-------------------------+{noformat}
It should be {{59.94}}.

 

More links:

[https://stackoverflow.com/questions/42158844/about-a-loss-of-precision-when-calculating-an-aggregate-sum-with-data-frames]

[https://stackoverflow.com/questions/44134497/spark-sql-sum-function-issues-on-double-value]

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to