Type inference rules
This document describes how Flink CDC data ingestion jobs merge columns of different types and infer the resulting types during database and table sharding and schema evolution.
Sharded column merging rules
Columns with the same name in different upstream sharded tables can sometimes have different types. You can use the route syntax to merge these tables into a single downstream table. The data ingestion job then uses the following type hierarchy to find a common supertype for both original types and sets this supertype as the column type in the downstream table.
The following types have additional rules when merged:
If the merged type is also time-based, its precision is the maximum of the source columns' precisions.
Fields of the DECIMAL type have precision and scale. When two DECIMAL fields have different precision and scale, they are merged according to the following rules:
The new scale is the maximum of the original scales.
Add the greater number of integer digits to the new scale to obtain the resulting new precision.
If the required precision after a merge exceeds the maximum DECIMAL precision of 38, the fractional part is truncated to preserve the integer part.