All Products
Search
Document Center

Realtime Compute for Apache Flink:Data type conversion

Last Updated:Jan 15, 2026

In addition to the standard Flink SQL data types, Realtime Compute for Apache Flink supports implicit type conversion. This topic describes the type conversion support matrix.

Usage notes

  • Realtime Compute for Apache Flink enables Legacy-Cast behavior by default, which includes cast operations that result from explicit and implicit type conversions.

    • Parameter description

      The table.exec.legacy-cast-behaviour parameter was introduced in Flink 1.15. This parameter is used to enforce a cast from a source data type to a target type for explicit and implicit type conversions. Note that the conversion may cause precision loss, value overflow, or return a null value. To ensure compatibility with previous versions, the default value is enabled for Realtime Compute for Apache Flink. The default value for Apache Flink is disabled.

    • About CAST

      By default, CAST returns a null value when a conversion exception occurs and does not throw an explicit error. In scenarios that require strict checks for abnormal values, you can set the table.exec.legacy-cast-behaviour=disabled parameter to make the task throw an explicit error when it encounters a data conversion exception.

    • About TRY_CAST

      You can use TRY_CAST for explicit type conversions. It returns null when a conversion exception occurs and does not cause the job to fail. This behavior is equivalent to using CAST when the table.exec.legacy-cast-behaviour parameter is set to enabled.

  • To handle null values, you can use explicit type conversion syntax, such as cast(null as target_type). For example, use cast(null as varchar). This practice avoids unexpected results, such as the "NULL" string or conversion exceptions.

Type conversion support matrix

Input type\Target type

null

boolean

tinyint

smallint

int

bigint

decimal

float

double

interval

date

time

timestamp

[var]char

[var]binary

variant

bitmap

null

I

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

-

bitmap

-

-

-

-

-

-

-

-

-

-

-

-

-

E

E

-

I

The symbols in the table mean the following:

  • E: Only explicit conversion is supported.

  • I: Implicit conversion is supported.

  • -: Conversion is not supported.

References

For more information about the SQL data types supported by the community, see Community Flink SQL data types.