You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Gengliang Wang (Jira)" <ji...@apache.org> on 2021/04/21 04:55:00 UTC

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

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

Gengliang Wang updated SPARK-34881:
-----------------------------------
        Parent: SPARK-35161
    Issue Type: Sub-task  (was: New Feature)

> New SQL Function: TRY_CAST
> --------------------------
>
>                 Key: SPARK-34881
>                 URL: https://issues.apache.org/jira/browse/SPARK-34881
>             Project: Spark
>          Issue Type: Sub-task
>          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