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

[jira] [Created] (SPARK-15612) Decimal `scale` must be less than `precision`

Dongjoon Hyun created SPARK-15612:
-------------------------------------

             Summary: Decimal `scale` must be less than `precision`
                 Key: SPARK-15612
                 URL: https://issues.apache.org/jira/browse/SPARK-15612
             Project: Spark
          Issue Type: Bug
          Components: SQL
            Reporter: Dongjoon Hyun


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