Skip to content

[cdc] Honor type mapping when deriving Debezium Avro column types - #11442

Open
hunter-cloud09 wants to merge 1 commit into
apache:masterfrom
hunter-cloud09:debezium-avro-type-mapping
Open

hunter-cloud09 wants to merge 1 commit into
apache:masterfrom
hunter-cloud09:debezium-avro-type-mapping

Conversation

@hunter-cloud09

@hunter-cloud09 hunter-cloud09 commented Nov 25, 2026 •

Copy link
Copy Markdown

Purpose

Linked issue: close #11441

DebeziumAvroRecordParser converts values with the configured --type_mapping
(DebeziumSchemaUtils.transformAvroRawValue(..., typeMapping, ...)), but derives
the column types with avroToPaimonDataType(schema), which always uses
TypeMapping.defaultMapping().

So with tinyint1-not-bool, a MySQL TINYINT(1) column (Debezium
column.propagate.source.type enabled) is created as BOOLEAN while its values
stay numbers. Values 0/1 are silently cast to false/true, and any other value
(e.g. a status code 2) fails the write:

Failed to convert field 'type' value 2 to type BOOLEAN. Waiting for schema update.
java.lang.RuntimeException: Unable to process element. Possibly a corrupt record: ...

and the job restarts forever. The Debezium JSON format is not affected.

This adds avroToPaimonDataType(Schema, TypeMapping) and passes the parser's
type mapping to it. The one-argument method keeps its behavior.

Tests

DebeziumSchemaUtilsTest#testAvroToPaimonDataTypeWithTypeMapping: a
TINYINT(1) Avro schema maps to BOOLEAN by default and to TINYINT with
tinyint1-not-bool.

DebeziumAvroRecordParser converts values with the configured type mapping
but derives the column types with the default mapping, so with
tinyint1-not-bool a MySQL TINYINT(1) column is created as BOOLEAN while its
values stay numbers, and any value other than 0/1 fails the write.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Debezium Avro: column types ignore type mapping, so TINYINT(1) becomes BOOLEAN with tinyint1-not-bool

1 participant