You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2018/08/13 08:27:00 UTC

[jira] [Commented] (SPARK-25098) ‘Cast’ will return NULL when input string starts/ends with special character(s)

    [ https://issues.apache.org/jira/browse/SPARK-25098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16577954#comment-16577954 ] 

Apache Spark commented on SPARK-25098:
--------------------------------------

User 'bingbai0912' has created a pull request for this issue:
https://github.com/apache/spark/pull/22089

> ‘Cast’ will return NULL when input string starts/ends with special character(s)
> -------------------------------------------------------------------------------
>
>                 Key: SPARK-25098
>                 URL: https://issues.apache.org/jira/browse/SPARK-25098
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.3.0
>            Reporter: ice bai
>            Priority: Major
>
> UDF ‘Cast’ will return NULL when input string starts/ends with special character, but hive doesn't.
> For examle, we get hour from a string ends with a blank :
> hive:
> ```
> hive> SELECT CAST(' 2018-08-13' AS DATE);//starts with a blank
> OK 
> 2018-08-13
> hive> SELECT HOUR('2018-08-13 17:20:07 );//ends with a blank
> OK
> 17
> ```
> spark-sql:
> ```
> spark-sql> SELECT CAST(' 2018-08-13' AS DATE);//starts with a blank
> NULL
> spark-sql> SELECT HOUR('2018-08-13 17:20:07 );//ends with a blank
> NULL
> ```
> All of the following UDFs will be affected:
> ```
> year
> month
> day
> hour
> minute
> second
> date_add
> date_sub
> ```



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