You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2016/05/27 10:30:13 UTC

[jira] [Assigned] (SPARK-15612) Raise exception if decimal `scale` >= `precision`

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

Apache Spark reassigned SPARK-15612:
------------------------------------

    Assignee: Apache Spark

> Raise exception if decimal `scale` >= `precision`
> -------------------------------------------------
>
>                 Key: SPARK-15612
>                 URL: https://issues.apache.org/jira/browse/SPARK-15612
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Dongjoon Hyun
>            Assignee: Apache Spark
>
> Currently, Spark raises exceptions only when decimal `scale` > `precision`. However, the value becames `null` if `scale` == `precision`. We should raise exceptions for that case, too.
> {code}
> scala> sql("select cast('1' as Decimal(2,1))")
> res0: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(2,1)): decimal(2,1)]
> scala> sql("select cast('1' as Decimal(2,2))")
> res1: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(2,2)): decimal(2,2)]
> scala> sql("select cast('1' as Decimal(2,3))")
> org.apache.spark.sql.catalyst.parser.ParseException:
> Decimal scale (3) cannot be greater than precision (2).
> scala> sql("select cast('1' as Decimal(2,1))").head
> res2: org.apache.spark.sql.Row = [1.0]
> scala> sql("select cast('1' as Decimal(2,2))").head
> res3: org.apache.spark.sql.Row = [null]
> {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