pyflink.table.expression.Expression.cast#
- Expression.cast(data_type: pyflink.table.types.DataType) pyflink.table.expression.Expression [source]#
Returns a new value being cast to type type. A cast error throws an exception and fails the job. When performing a cast operation that may fail, like STRING to INT, one should rather use try_cast, in order to handle errors. If “table.exec.legacy-cast-behaviour” is enabled, cast behaves like try_cast.
E.g. lit(“4”).cast(DataTypes.INT()) returns 42; lit(null).cast(DataTypes.STRING()) returns NULL of type STRING; lit(“non-number”).cast(DataTypes.INT()) throws an exception and fails the job.
New in version 1.12.0.