You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yin Huai (JIRA)" <ji...@apache.org> on 2015/07/23 00:47:04 UTC
[jira] [Updated] (SPARK-9264) When dealing with
Union/Intersect/Except, we cast FloatType/DoubleType to the wrong
DecimalType
[ https://issues.apache.org/jira/browse/SPARK-9264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yin Huai updated SPARK-9264:
----------------------------
Description:
The problem is https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala#L361-L362. When we union/intersect/except, for a column, if the data type of it in one table is a fixed precision decimal type and that in another table is a FloatType/DoubleType, we cast FloatType to Decimal(7, 7) and cast DoubleType to Decimal(15, 15), respectively. It is wrong.
I tried the following in 1.4
{code}
sqlContext.sql("select a from (select cast(200.101 as double) as a union all select cast(200.101 as decimal(6,3)) as a) tmp").show
{code}
I got
{code}
+-------------------+
| a|
+-------------------+
| null|
|200.101000000000000|
+-------------------+
{code}
was:The problem is https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala#L361-L362. When we union/intersect/except, for a column, if the data type of it in one table is a fixed precision decimal type and that in another table is a FloatType/DoubleType, we cast FloatType to Decimal(7, 7) and cast DoubleType to Decimal(15, 15), respectively. It is wrong.
> When dealing with Union/Intersect/Except, we cast FloatType/DoubleType to the wrong DecimalType
> -----------------------------------------------------------------------------------------------
>
> Key: SPARK-9264
> URL: https://issues.apache.org/jira/browse/SPARK-9264
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 1.4.0
> Reporter: Yin Huai
> Priority: Blocker
>
> The problem is https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala#L361-L362. When we union/intersect/except, for a column, if the data type of it in one table is a fixed precision decimal type and that in another table is a FloatType/DoubleType, we cast FloatType to Decimal(7, 7) and cast DoubleType to Decimal(15, 15), respectively. It is wrong.
> I tried the following in 1.4
> {code}
> sqlContext.sql("select a from (select cast(200.101 as double) as a union all select cast(200.101 as decimal(6,3)) as a) tmp").show
> {code}
> I got
> {code}
> +-------------------+
> | a|
> +-------------------+
> | null|
> |200.101000000000000|
> +-------------------+
> {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