You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2019/11/21 03:37:01 UTC

[jira] [Resolved] (SPARK-29980) Whitespaces handling for Cast and BinaryOperation between StringType and NumericTypes

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

Hyukjin Kwon resolved SPARK-29980.
----------------------------------
    Resolution: Duplicate

> Whitespaces handling for Cast and BinaryOperation between StringType and NumericTypes
> -------------------------------------------------------------------------------------
>
>                 Key: SPARK-29980
>                 URL: https://issues.apache.org/jira/browse/SPARK-29980
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.0.0
>            Reporter: Kent Yao
>            Priority: Major
>
> Here is a case, let see how it goes in different SQL engines.
> {code:sql}
> select cast('1 ' as int) as v1, '1 ' = 1 as v2
> {code}
> h3. spark 1.6
> {code:java}
> NULL	true
> {code}
> h3. spark 2.1
> {code:java}
> NULL	true
> {code}
> h3. spark 2.2
> {code:java}
> NULL	NULL
> {code}
> h3. spark 2.3
> {code:java}
> NULL	NULL
> {code}
> h3. spark 2.4
> {code:java}
> NULL	NULL
> {code}
> h3. hive
> {code:java}
> NULL	true
> {code}
> h3. PostgreSQL
> {code:sql}
> postgres=# select cast('1 ' as int) as v1, '1 ' = 1 as v2;
>  v1 | v2
> ----+----
>   1 | t
> (1 row)
> {code}
> h3. presto
> {code:sql}
> presto> select cast('1 ' as int) as v1, '1 ' = 1 as v2;
> Query 20191120_060530_00002_f5kcs failed: line 1:38: '=' cannot be applied to varchar(2), integer
> select cast('1 ' as int) as v1, '1 ' = 1 as v2
> presto> select cast('1 ' as int) as v1, '1 ' = '1 ' as v2;
> Query 20191120_060545_00003_f5kcs failed: Cannot cast '1 ' to INT
> {code}
> Our behavior is unstable because type coercion changed since 2.2.
> Personally, I think What PostgreSQL and Presto does here is more reasonable and consistent



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org