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.cast

pyflink.table.expression.Expression.cast#

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

Added in version 1.12.0.

previous

pyflink.table.expression.Expression.alias

next

pyflink.table.expression.Expression.try_cast

On this page
  • Expression.cast()

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.