You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2018/09/05 23:45:00 UTC
[jira] [Resolved] (SPARK-23774) `Cast` to CHAR/VARCHAR should
truncate the values
[ https://issues.apache.org/jira/browse/SPARK-23774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dongjoon Hyun resolved SPARK-23774.
-----------------------------------
Resolution: Won't Do
Per review comments, we will revisit this when we can support CHAR/VARCHAR natively.
> `Cast` to CHAR/VARCHAR should truncate the values
> -------------------------------------------------
>
> Key: SPARK-23774
> URL: https://issues.apache.org/jira/browse/SPARK-23774
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.1.2, 2.2.1, 2.3.0
> Reporter: Dongjoon Hyun
> Priority: Major
>
> This issue aims to fix the following `CAST` behavior on `CHAR/VARCHAR` types.
> Since HiveStringType is used only in parsing, this PR is also about parsing.
> *Spark*
> {code}
> scala> sql("SELECT CAST('123' AS CHAR(1)), CAST('123' AS VARCHAR(1))").show
> +-------------------+-------------------+
> |CAST(123 AS STRING)|CAST(123 AS STRING)|
> +-------------------+-------------------+
> | 123| 123|
> +-------------------+-------------------+
> scala> sql("SELECT CAST('123' AS CHAR(0)), CAST('123' AS VARCHAR(0))").show
> +-------------------+-------------------+
> |CAST(123 AS STRING)|CAST(123 AS STRING)|
> +-------------------+-------------------+
> | 123| 123|
> +-------------------+-------------------+
> {code}
> *Hive*
> {code}
> hive> SELECT CAST('123' AS CHAR(1)), CAST('123' AS VARCHAR(1));
> OK
> 1 1
> hive> SELECT CAST('123' AS CHAR(0)), CAST('123' AS VARCHAR(0));
> FAILED: RuntimeException Char length 0 out of allowed range [1, 255]
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org