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

Wenchen Fan commented on SPARK-28024:
-------------------------------------

these are the behaviors of Java:
{code}
scala> java.lang.Float.valueOf("10e-70")
res0: Float = 0.0
scala> java.lang.StrictMath.exp(-1.2345678901234E200)
res1: Double = 0.0
{code}

Although it's not officially documented, Spark arithmetic follows Java since 
the very beginning. I won't treat them as correctness bug simply because they 
are not ANSI-compliance. You won't report this as correctness bug to JDK, right?

I'd suggest we close this ticket. These behaviors are well defined (follows 
Java). We need to improve our document though. BTW when we complete the ANSI 
mode and turn it on by default, these problems would go away.

> Incorrect numeric values when out of range
> ------------------------------------------
>
>                 Key: SPARK-28024
>                 URL: https://issues.apache.org/jira/browse/SPARK-28024
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.2, 2.1.3, 2.2.3, 2.3.4, 2.4.4, 3.0.0
>            Reporter: Yuming Wang
>            Priority: Blocker
>              Labels: correctness
>         Attachments: SPARK-28024.png
>
>
> For example
> Case 1:
> {code:sql}
> select tinyint(128) * tinyint(2); -- 0
> select smallint(2147483647) * smallint(2); -- -2
> select int(2147483647) * int(2); -- -2
> SELECT smallint((-32768)) * smallint(-1); -- -32768
> {code}
> Case 2:
> {code:sql}
> spark-sql> select cast('10e-70' as float), cast('-10e-70' as float);
> 0.0   -0.0
> {code}
> Case 3:
> {code:sql}
> spark-sql> select cast('10e-400' as double), cast('-10e-400' as double);
> 0.0   -0.0
> {code}
> Case 4:
> {code:sql}
> spark-sql> select exp(-1.2345678901234E200);
> 0.0
> postgres=# select exp(-1.2345678901234E200);
> ERROR:  value overflows numeric format
> {code}



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

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

Reply via email to