spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dongjoon Hyun (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SPARK-15612) Decimal `scale` must be less than `precision`
Date Fri, 27 May 2016 10:23:12 GMT
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


Mime
View raw message