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 2021/04/01 04:10:00 UTC

[jira] [Commented] (SPARK-34881) New SQL Function: TRY_CAST

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

Apache Spark commented on SPARK-34881:
--------------------------------------

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

> New SQL Function: TRY_CAST
> --------------------------
>
>                 Key: SPARK-34881
>                 URL: https://issues.apache.org/jira/browse/SPARK-34881
>             Project: Spark
>          Issue Type: New Feature
>          Components: SQL
>    Affects Versions: 3.2.0
>            Reporter: Gengliang Wang
>            Assignee: Gengliang Wang
>            Priority: Major
>             Fix For: 3.2.0
>
>
> Add a new SQL function try_cast. try_cast is identical to CAST with `spark.sql.ansi.enabled` as true, except it returns NULL instead of raising an error. This expression has one major difference from `cast` with `spark.sql.ansi.enabled` as true: when the source value can't be stored in the target integral(Byte/Short/Int/Long) type, `try_cast` returns null instead of returning the low order bytes of the source value.
> This is learned from Google BigQuery and Snowflake:
> https://docs.snowflake.com/en/sql-reference/functions/try_cast.html
> https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#safe_casting



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