You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Josh Rosen (JIRA)" <ji...@apache.org> on 2015/07/02 23:19:05 UTC
[jira] [Created] (SPARK-8802)
Decimal.apply(BigDecimal).toBigDecimal may throw NumberFormatException
Josh Rosen created SPARK-8802:
---------------------------------
Summary: 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-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org