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

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

Kent Yao created SPARK-29980:
--------------------------------

             Summary: 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


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