[ 
https://issues.apache.org/jira/browse/SPARK-24362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yuming Wang updated SPARK-24362:
--------------------------------
    Description: 
 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]

 

  was:
 

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]

 


> 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
>            Priority: Major
>
>  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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to