diff --git a/pkg/redshift/redshift.go b/pkg/redshift/redshift.go index d419acb6..ec28d4d9 100644 --- a/pkg/redshift/redshift.go +++ b/pkg/redshift/redshift.go @@ -1392,6 +1392,13 @@ func GetRedshiftDataType(sqlType, debeziumType, sourceColType, } } + // BIGINT UNSIGNED propagates no column length, and the default + // numeric(18,0) cannot hold its full range: COPY fails with + // "Overflow for NUMERIC(18,0)". Size it to 20 digits. + if sourceColType == "bigint unsigned" && sourceColLength == "" { + sourceColLength = "20" + } + return applyLength( RedshiftToMysqlCharacterRatio, redshiftType, diff --git a/pkg/redshift/redshift_test.go b/pkg/redshift/redshift_test.go index fa49665d..a8251706 100644 --- a/pkg/redshift/redshift_test.go +++ b/pkg/redshift/redshift_test.go @@ -337,6 +337,39 @@ func TestRedshiftDataTypeGet(t *testing.T) { expectedResult: "boolean", expectError: false, }, + { + name: "test29: BIGINT UNSIGNED without length covers full range", + sqlType: "mysql", + debeziumType: "string", + sourceColType: "BIGINT UNSIGNED", + sourceColLength: "", + sourceColScale: "", + columnMasked: false, + expectedResult: "numeric(20,0)", + expectError: false, + }, + { + name: "test30: BIGINT UNSIGNED with explicit length is respected", + sqlType: "mysql", + debeziumType: "string", + sourceColType: "BIGINT UNSIGNED", + sourceColLength: "22", + sourceColScale: "", + columnMasked: false, + expectedResult: "numeric(22,0)", + expectError: false, + }, + { + name: "test31: BIGINT UNSIGNED masked stays varchar", + sqlType: "mysql", + debeziumType: "string", + sourceColType: "BIGINT UNSIGNED", + sourceColLength: "", + sourceColScale: "", + columnMasked: true, + expectedResult: "character varying(50)", + expectError: false, + }, } for _, tc := range tests { diff --git a/pkg/redshiftloader/load_processor.go b/pkg/redshiftloader/load_processor.go index f419c033..c75d422d 100644 --- a/pkg/redshiftloader/load_processor.go +++ b/pkg/redshiftloader/load_processor.go @@ -577,7 +577,6 @@ func (b *loadProcessor) migrateTable( if err != nil { return err } - return err } err = tx.Commit()