From d59e97e99a8cf2dd0ec0251e8adff260ab8c5337 Mon Sep 17 00:00:00 2001 From: Will Donnelly Date: Thu, 14 Mar 2024 14:30:35 -0500 Subject: [PATCH] source-mysql: Omit unexpected `DB_ROW_HASH_1` column values See https://github.com/estuary/connectors/issues/1344 for the full explanation, but this commit adds a special-case to our document value translation logic to exclude columns by the name of `DB_ROW_HASH_1` for which we have no type information. There is no accompanying test because this can only be reproduced on MariaDB and we use MySQL for our default test setup, but I have tested this locally and confirmed that it fixes what would otherwise be a capture error. --- source-mysql/discovery.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source-mysql/discovery.go b/source-mysql/discovery.go index 2a4c051c01..8fd678d07d 100644 --- a/source-mysql/discovery.go +++ b/source-mysql/discovery.go @@ -171,6 +171,15 @@ func (db *mysqlDatabase) translateRecordFields(columnTypes map[string]interface{ return nil } for id, val := range f { + // MariaDB versions 10.4 and up include a synthetic `DB_ROW_HASH_1` column in the + // binlog row change events for certain tables with unique hash indices (see issue + // https://github.com/estuary/connectors/issues/1344). In such cases we won't have + // any type information for the column, but we also don't want it anyway, so as a + // special case we just delete the 'DB_ROW_HASH_1' property from the document. + if id == "DB_ROW_HASH_1" && columnTypes[id] == nil { + delete(f, id) + continue + } var translated, err = db.translateRecordField(columnTypes[id], val) if err != nil { return fmt.Errorf("error translating field %q value %v: %w", id, val, err)