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

Liang-Chi Hsieh updated SPARK-8677:
-----------------------------------
    Description: 
Please refer to [BigDecimal 
doc|http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html]:
{quote}
... the rounding mode setting of a MathContext object with a precision setting 
of 0 is not used and thus irrelevant. In the case of divide, the exact quotient 
could have an infinitely long decimal expansion; for example, 1 divided by 3.
{quote}

Because we provide a MathContext.UNLIMITED in toBigDecimal, Decimal divide 
operation will throw the following exception:
{code}
val decimal = Decimal(1.0, 10, 3) / Decimal(3.0, 10, 3)
[info]   java.lang.ArithmeticException: Non-terminating decimal expansion; no 
exact representable decimal result.
[info]   at java.math.BigDecimal.divide(BigDecimal.java:1690)
[info]   at java.math.BigDecimal.divide(BigDecimal.java:1723)
[info]   at scala.math.BigDecimal.$div(BigDecimal.scala:256)
[info]   at org.apache.spark.sql.types.Decimal.$div(Decimal.scala:272)
{code}


  was:
Please refer to [BigDecimal 
doc|http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html]
{quote}
... the rounding mode setting of a MathContext object with a precision setting 
of 0 is not used and thus irrelevant. In the case of divide, the exact quotient 
could have an infinitely long decimal expansion; for example, 1 divided by 3.
{quote}

Because we provide a MathContext.UNLIMITED in toBigDecimal, Decimal divide 
operation will throw the following exception:
{code}
val decimal = Decimal(1.0, 10, 3) / Decimal(3.0, 10, 3)
[info]   java.lang.ArithmeticException: Non-terminating decimal expansion; no 
exact representable decimal result.
[info]   at java.math.BigDecimal.divide(BigDecimal.java:1690)
[info]   at java.math.BigDecimal.divide(BigDecimal.java:1723)
[info]   at scala.math.BigDecimal.$div(BigDecimal.scala:256)
[info]   at org.apache.spark.sql.types.Decimal.$div(Decimal.scala:272)
{code}



> Decimal divide operation throws ArithmeticException
> ---------------------------------------------------
>
>                 Key: SPARK-8677
>                 URL: https://issues.apache.org/jira/browse/SPARK-8677
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Liang-Chi Hsieh
>
> Please refer to [BigDecimal 
> doc|http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html]:
> {quote}
> ... the rounding mode setting of a MathContext object with a precision 
> setting of 0 is not used and thus irrelevant. In the case of divide, the 
> exact quotient could have an infinitely long decimal expansion; for example, 
> 1 divided by 3.
> {quote}
> Because we provide a MathContext.UNLIMITED in toBigDecimal, Decimal divide 
> operation will throw the following exception:
> {code}
> val decimal = Decimal(1.0, 10, 3) / Decimal(3.0, 10, 3)
> [info]   java.lang.ArithmeticException: Non-terminating decimal expansion; no 
> exact representable decimal result.
> [info]   at java.math.BigDecimal.divide(BigDecimal.java:1690)
> [info]   at java.math.BigDecimal.divide(BigDecimal.java:1723)
> [info]   at scala.math.BigDecimal.$div(BigDecimal.scala:256)
> [info]   at org.apache.spark.sql.types.Decimal.$div(Decimal.scala:272)
> {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