GitHub user JoshRosen opened a pull request:

    https://github.com/apache/spark/pull/7198

    [SPARK-8802] [WIP] [SQL] Decimal.apply(BigDecimal).toBigDecimal may throw 
NumberFormatException

    There are 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:
    
    ```scala
    val x = BigDecimal(BigInt("18889465931478580854784"), -2147483648)
    assert(Decimal(x).toBigDecimal === x)
    ```
    
    fails with the following exception:
    
    ```scala
    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)
    ```
    
    This PR adds a failing regression test for this issue.  I'll try to fix 
this shortly.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/JoshRosen/spark SPARK-8802

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/7198.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #7198
    
----
commit 6d41282b5d082ca53a0692f3a8010dcdbc7bc666
Author: Josh Rosen <[email protected]>
Date:   2015-07-02T21:19:52Z

    Add failing regression test for SPARK-8802

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to