spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dongjoon Hyun (JIRA)" <>
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
             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,
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))")
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]

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message