You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yuming Wang (JIRA)" <ji...@apache.org> on 2019/07/31 05:49:00 UTC
[jira] [Resolved] (SPARK-28348) Avoid cast twice for decimal type
[ https://issues.apache.org/jira/browse/SPARK-28348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuming Wang resolved SPARK-28348.
---------------------------------
Resolution: Won't Fix
> Avoid cast twice for decimal type
> ---------------------------------
>
> Key: SPARK-28348
> URL: https://issues.apache.org/jira/browse/SPARK-28348
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.3.3
> Reporter: Yuming Wang
> Priority: Major
>
> Spark 2.1:
> {code:scala}
> scala> sql("select cast(cast(-34338492.215397047 as decimal(38, 10)) * cast(-34338492.215397047 as decimal(38, 10)) as decimal(38, 18))").show(false);
> +-------------------------------------------------------------------------------------------------------------------+
> |CAST((CAST(-34338492.215397047 AS DECIMAL(38,10)) * CAST(-34338492.215397047 AS DECIMAL(38,10))) AS DECIMAL(38,18))|
> +-------------------------------------------------------------------------------------------------------------------+
> |1179132047626883.596862135856320209 |
> +-------------------------------------------------------------------------------------------------------------------+
> {code}
> Spark 2.3:
> {code:scala}
> scala> sql("select cast(cast(-34338492.215397047 as decimal(38, 10)) * cast(-34338492.215397047 as decimal(38, 10)) as decimal(38, 18))").show(false);
> +-------------------------------------------------------------------------------------------------------------------+
> |CAST((CAST(-34338492.215397047 AS DECIMAL(38,10)) * CAST(-34338492.215397047 AS DECIMAL(38,10))) AS DECIMAL(38,18))|
> +-------------------------------------------------------------------------------------------------------------------+
> |1179132047626883.596862000000000000 |
> +-------------------------------------------------------------------------------------------------------------------+
> {code}
> I think we do not need to cast result to {{decimal(38, 6)}} and then cast result to {{decimal(38, 18)}} for this case.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org