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.