spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apache Spark (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (SPARK-15612) Raise exception if decimal `scale` >= `precision`
Date Fri, 27 May 2016 10:30:13 GMT

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

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

    Assignee:     (was: 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
>
> 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