Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flow/connectors/mysql/cdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,14 @@ func TestShouldReportColumnTypeChange(t *testing.T) {
{"maria inet to string", types.QValueKindINET, types.QValueKindString, protos.MySqlFlavor_MYSQL_MARIA, true},
// Bytes on the wire for a non-uuid/inet schema kind is a real change.
{"maria string to bytes", types.QValueKindString, types.QValueKindBytes, protos.MySqlFlavor_MYSQL_MARIA, true},
// Known TABLE_MAP_EVENT limitations.
{"mysql bool as int8", types.QValueKindBoolean, types.QValueKindInt8, protos.MySqlFlavor_MYSQL_MYSQL, false},
{"maria bool as int8", types.QValueKindBoolean, types.QValueKindInt8, protos.MySqlFlavor_MYSQL_MARIA, false},
{"mysql enum as string", types.QValueKindEnum, types.QValueKindString, protos.MySqlFlavor_MYSQL_MYSQL, false},
{"maria enum as string", types.QValueKindEnum, types.QValueKindString, protos.MySqlFlavor_MYSQL_MARIA, false},
// Other changes from bool or enum must still be reported.
{"bool to int16", types.QValueKindBoolean, types.QValueKindInt16, protos.MySqlFlavor_MYSQL_MYSQL, true},
{"enum to integer", types.QValueKindEnum, types.QValueKindInt32, protos.MySqlFlavor_MYSQL_MYSQL, true},
// Ordinary type change.
{"int to bigint", types.QValueKindInt32, types.QValueKindInt64, protos.MySqlFlavor_MYSQL_MYSQL, true},
} {
Expand Down
8 changes: 8 additions & 0 deletions flow/connectors/mysql/type_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,13 @@ func shouldReportColumnTypeChange(schemaKind, wireKind types.QValueKind, flavor
(schemaKind == types.QValueKindUUID || schemaKind == types.QValueKindINET) {
return false
}
if schemaKind == types.QValueKindBoolean && wireKind == types.QValueKindInt8 {
// TABLE_MAP omits TINYINT display width, so TINYINT(1) arrives as int8.
return false
}
if schemaKind == types.QValueKindEnum && wireKind == types.QValueKindString {
// TABLE_MAP encodes ENUM as STRING.
return false
}
return true
}
Loading