You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Marios Trivyzas (Jira)" <ji...@apache.org> on 2021/10/20 13:51:00 UTC

[jira] [Assigned] (FLINK-24385) Add TRY_CAST function to be able to handle errors

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

Marios Trivyzas reassigned FLINK-24385:
---------------------------------------

    Assignee: Marios Trivyzas

> Add TRY_CAST function to be able to handle errors
> -------------------------------------------------
>
>                 Key: FLINK-24385
>                 URL: https://issues.apache.org/jira/browse/FLINK-24385
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>            Reporter: Marios Trivyzas
>            Assignee: Marios Trivyzas
>            Priority: Major
>
> Currently, *CAST* is returning null when the conversion requested fails, whereas normally in SQL it would just throw an error. Maybe it would be better to change the implementation of *CAST* to throw errors on failed conversions, and introduce *TRY_CAST* which would return null in such cases. Then with a simple wrapping of a *TRY_CAST* expression with *COALESCE* the user can also use an alternative default value to be returned instead of null. e..g:
> {{}}{{SELECT COALESCE(TRY_CAST(col1 AS INT),  -1) FROM test}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)