Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
    • TableEnvironment
    • Table
    • Data Types
    • Window
    • Expressions
    • User Defined Functions
    • Descriptors
    • StatementSet
    • Catalog
  • PyFlink DataStream
  • PyFlink Common

pyflink.table.expression.Expression.try_cast#

Expression.try_cast(data_type: pyflink.table.types.DataType) → pyflink.table.expression.Expression[source]#

Like cast, but in case of error, returns NULL rather than failing the job.

E.g. lit(“42”).try_cast(DataTypes.INT()) returns 42; lit(null).try_cast(DataTypes.STRING()) returns NULL of type STRING; lit(“non-number”).cast(DataTypes.INT()) returns NULL of type INT. coalesce(lit(“non-number”).cast(DataTypes.INT()), lit(0)) returns 0 of type INT.

New in version 1.12.0.

previous

pyflink.table.expression.Expression.cast

next

pyflink.table.expression.Expression.asc

Show Source

Created using Sphinx 4.5.0.