Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-24403 Improve behaviour of CAST
  3. FLINK-24385

Add TRY_CAST function to be able to handle errors

    XMLWordPrintableJSON

Details

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              matriv Marios Trivyzas
              matriv Marios Trivyzas
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: