All Products
Search
Document Center

Realtime Compute for Apache Flink:Data type conversion

Last Updated:Dec 11, 2025

In addition to explicit casting pairs supported by Apache Flink, Realtime Compute for Apache Flink also supports implicit type conversion. This topic describes the data type conversion matrix.

Usage notes

  • Realtime Compute for Apache Flink implements legacy casting by default for explicit and implicit type conversions. Take note of the following:

    • Parameter details

      The table.exec.legacy-cast-behaviour parameter, introduced in Apache Flink 1.15, dictates how explicit and implicit type conversions are handled. When enabled, it forces a cast from a source type to a target type, which may result in precision loss, value overflow, or null returns. Default value: enabled for Realtime Compute for Apache Flink, and disabled for Apache Flink.

    • CAST

      By default, CAST returns null when a conversion error occurs and does not throw an explicit error. In scenarios that require strict checks for abnormal values, set table.exec.legacy-cast-behaviour=disabled to throw an explicit error when a data conversion error is encountered.

    • TRY_CAST

      Use TRY_CAST for explicit type conversions. It returns null when a conversion error occurs and does not fail the job. This is equivalent to using CAST with table.exec.legacy-cast-behaviour set to enabled.

  • Use explicit conversion cast(null as target_type) to handle null values and prevents unexpected results, such as obtaining "NULL" strings or triggering exceptions. For example, to convert a null value to a varchar type, the appropriate syntax is cast(null as varchar).

Data type conversion matrix

Input\Target

null

boolean

tinyint

smallint

int

bigint

decimal

float

double

interval

date

time

timestamp

[var]char

[var]binary

variant

null

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

boolean

-

I

E

E

E

E

E

E

E

-

-

-

-

I

-

E

tinyint

-

E

I

I

I

I

I

I

I

E

-

-

E

I

-

E

smallint

-

E

I

I

I

I

I

I

I

E

-

-

E

I

-

E

int

-

E

I

I

I

I

I

I

I

E

-

-

E

I

-

E

bigint

-

E

I

I

I

I

I

I

I

E

-

-

E

I

-

E

decimal

-

E

I

I

I

I

I

I

I

E

-

-

E

I

-

E

float

-

E

I

I

I

I

I

I

I

-

-

-

E

I

-

E

double

-

E

I

I

I

I

I

I

I

-

-

-

E

I

-

E

interval

-

-

E

E

E

E

E

-

-

I

-

-

-

E

-

E

date

-

-

-

-

-

-

-

-

-

-

I

-

I

I

-

E

time

-

-

-

-

-

-

-

-

-

-

-

I

E

I

-

E

timestamp

-

-

E

E

E

E

E

E

E

-

I

E

I

I

-

E

[var]char

-

E

I

I

I

I

I

I

I

I

I

I

I

I

I

E

[var]binary

-

-

-

-

-

-

-

-

-

-

E

E

E

I

I

E

variant

-

E

E

E

E

E

E

E

E

E

E

E

E

E

E

I

Notes:

  • E: only explicit conversion is supported.

  • I: implicit conversion is supported.

  • -: data type conversion is not supported.

Reference

For information about casting pairs supported by Apache Flink, see Data types.