Skip to main content

Schema Evolution and Type Mapping

This page describes the Paimon CDC actions and CDC ingestion sinks. The schema changes that reach Paimon depend on the source connector and event format. Flink CDC YAML pipelines have their own schema-change handling; see the relevant pipeline connector documentation.

Schema Change Evolution

The action compares incoming field names and types with the target schema and applies supported changes. It does not replicate every source DDL statement.

Source changeEffect on the Paimon target
Add a columnAdd the new field when its schema reaches the sink.
Widen a string or binary typeIncrease the target length.
Widen an integer or floating-point typeWiden within the corresponding type family, such as INT to BIGINT or FLOAT to DOUBLE.
Change a non-string type to a string typeRequires --type_mapping allow-non-string-to-string; disabled by default.
Drop a columnKeep the existing target column.
Rename a columnTreat the new name as a new column; keep the old column.
Rename a tableDo not rename the existing Paimon table. Source selection and routing determine whether events for the new name are consumed.

The sink also handles decimal precision/scale changes, temporal precision changes, and compatible nested types. These changes must pass Paimon's schema validation. A source type narrowing does not narrow an existing target type within the string, binary, integer, or floating-point family. Incompatible conversions can fail the job; do not assume an unsupported change will be ignored.

Column evolution does not migrate primary keys or partition keys. When reusing a target table, make sure its schema and keys are compatible with the source and the action arguments.

Special Data Type Mapping

The following mappings apply where the source parser exposes the corresponding type information:

Source type or conditionPaimon type
MySQL TINYINT(1) or BIT(1)BOOLEAN
MySQL BIGINT UNSIGNED, BIGINT UNSIGNED ZEROFILL, or SERIALDECIMAL(20, 0)
MySQL BINARY(n)VARBINARY(n); preserves the length of the binlog byte value
PostgreSQL NUMERIC without declared precision and scaleDECIMAL(38, 18)
MySQL TIMETIME; exposed as STRING to Hive

For MongoDB fields and message formats that do not carry field types, see the source guide. Type mapping cannot recover metadata that is absent from the event.

Mapping Options

Pass a comma-separated list using --type_mapping. Option names use hyphens:

--type_mapping tinyint1-not-bool,to-nullable
OptionEffect
tinyint1-not-boolMap MySQL TINYINT(1) to TINYINT instead of BOOLEAN.
to-nullableIgnore source NOT NULL constraints, except for primary keys.
to-stringMap source types to STRING where supported by the source parser.
char-to-stringMap MySQL CHAR(n) and VARCHAR(n) to STRING.
longtext-to-bytesMap MySQL LONGTEXT to BYTES.
decimal-no-changeKeep an existing target DECIMAL column's type unchanged during schema evolution.
bigint-unsigned-to-bigintMap MySQL unsigned BIGINT variants to BIGINT. Use only when all values fit in a signed 64-bit integer.
allow-non-string-to-stringAllow evolution of an existing non-string column to a string type.

MySQL-specific options do not change the behavior of unrelated source parsers. Initial type mapping and later schema evolution are separate steps: to-string determines the mapped schema, while allow-non-string-to-string allows an existing target column to evolve.

Next Steps

  • Add computed columns when deriving partition values.
  • Check the source guide for schema discovery, key requirements, and source-specific limits.