You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Wenchen Fan (Jira)" <ji...@apache.org> on 2021/07/13 12:31:01 UTC

[jira] [Resolved] (SPARK-36081) Update the document about the behavior change of trimming characters for cast

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

Wenchen Fan resolved SPARK-36081.
---------------------------------
    Fix Version/s: 3.1.3
                   3.2.0
                   3.0.4
       Resolution: Fixed

Issue resolved by pull request 33287
[https://github.com/apache/spark/pull/33287]

> Update the document about the behavior change of trimming characters for cast
> -----------------------------------------------------------------------------
>
>                 Key: SPARK-36081
>                 URL: https://issues.apache.org/jira/browse/SPARK-36081
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.0.3, 3.1.2, 3.2.0, 3.3.0
>            Reporter: Kousuke Saruta
>            Assignee: Kousuke Saruta
>            Priority: Major
>             Fix For: 3.0.4, 3.2.0, 3.1.3
>
>
> sql-migration-guide.md mentions about the behavior of cast like as follows.
> {code}
> In Spark 3.0, when casting string value to integral types(tinyint, smallint, int and bigint), datetime types(date, timestamp and interval) and boolean type, the leading and trailing whitespaces (<= ASCII 32) will be trimmed before converted to these type values, for example, `cast(' 1\t' as int)` results `1`, `cast(' 1\t' as boolean)` results `true`, `cast('2019-10-10\t as date)` results the date value `2019-10-10`. In Spark version 2.4 and below, when casting string to integrals and booleans, it does not trim the whitespaces from both ends; the foregoing results is `null`, while to datetimes, only the trailing spaces (= ASCII 32) are removed.
> {code}
> In fact,  select cast('2019-10-10\b' as date); returns 2019-10-10 in Spark 3.0.0. 
> But SPARK-32559 changed this behavior and since 3.0.1, the query returns NULL.



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