Skip to main content
Ctrl+K
PyFlink 1.20+vvr.11.7.dev0 documentation - Home PyFlink 1.20+vvr.11.7.dev0 documentation - Home
  • API Reference
  • Examples
  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
    • TableEnvironment
    • Table
    • Data Types
    • Window
    • Expressions
    • User Defined Functions
    • Descriptors
    • StatementSet
    • Catalog
  • PyFlink DataStream
  • PyFlink DataFrame
  • PyFlink Common
  • API Reference
  • PyFlink Table
  • Expressions
  • pyflink.table.expression.Expression.try_cast

pyflink.table.expression.Expression.try_cast#

Expression.try_cast(data_type: DataType) → 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.

Added in version 1.12.0.

previous

pyflink.table.expression.Expression.cast

next

pyflink.table.expression.Expression.asc

On this page
  • Expression.try_cast()

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.