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

Reynold Xin commented on SPARK-8802:
------------------------------------

[~joshrosen] is this still a problem given the other decimal work?


> Decimal.apply(BigDecimal).toBigDecimal may throw NumberFormatException
> ----------------------------------------------------------------------
>
>                 Key: SPARK-8802
>                 URL: https://issues.apache.org/jira/browse/SPARK-8802
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.5.0
>            Reporter: Josh Rosen
>            Assignee: Josh Rosen
>            Priority: Minor
>
> There exist certain BigDecimals that can be converted into Spark SQL's 
> Decimal class but which produce Decimals that cannot be converted back to 
> BigDecimal without throwing NumberFormatException.
> For instance:
> {code}
> val x = BigDecimal(BigInt("18889465931478580854784"), -2147483648)
> assert(Decimal(x).toBigDecimal === x)
> {code}
> will fail with an exception:
> {code}
> java.lang.NumberFormatException
>       at java.math.BigDecimal.<init>(BigDecimal.java:511)
>       at java.math.BigDecimal.<init>(BigDecimal.java:757)
>       at scala.math.BigDecimal$.apply(BigDecimal.scala:119)
>       at scala.math.BigDecimal.apply(BigDecimal.scala:324)
>       at org.apache.spark.sql.types.Decimal.toBigDecimal(Decimal.scala:142)
>       at 
> org.apache.spark.sql.types.decimal.DecimalSuite$$anonfun$2.apply$mcV$sp(DecimalSuite.scala:62)
>       at 
> org.apache.spark.sql.types.decimal.DecimalSuite$$anonfun$2.apply(DecimalSuite.scala:60)
>       at 
> org.apache.spark.sql.types.decimal.DecimalSuite$$anonfun$2.apply(DecimalSuite.scala:60)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to