From d6d90bf28e76507366f70efe3dc54093e998c49f Mon Sep 17 00:00:00 2001 From: Robin Tang <rtang.cs@gmail.com> Date: Thu, 17 Oct 2024 08:39:20 -0700 Subject: [PATCH 1/3] Clean up. --- lib/cdc/util/relational_event.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cdc/util/relational_event.go b/lib/cdc/util/relational_event.go index 2c500f412..bd58fc708 100644 --- a/lib/cdc/util/relational_event.go +++ b/lib/cdc/util/relational_event.go @@ -77,10 +77,11 @@ func (s *SchemaEventPayload) GetTableName() string { } func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConfig) (map[string]any, error) { + var err error var retMap map[string]any - if len(s.Payload.After) == 0 { + switch s.Operation() { + case "d": if len(s.Payload.Before) > 0 { - var err error retMap, err = s.parseAndMutateMapInPlace(s.Payload.Before, debezium.Before) if err != nil { return nil, err @@ -100,8 +101,7 @@ func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConf for k, v := range pkMap { retMap[k] = v } - } else { - var err error + case "r", "u", "c": retMap, err = s.parseAndMutateMapInPlace(s.Payload.After, debezium.After) if err != nil { return nil, err From 06300e650c15c0dffc5e798265937849a39a34a1 Mon Sep 17 00:00:00 2001 From: Robin Tang <rtang.cs@gmail.com> Date: Thu, 17 Oct 2024 08:40:35 -0700 Subject: [PATCH 2/3] Adding default case. --- lib/cdc/util/relational_event.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cdc/util/relational_event.go b/lib/cdc/util/relational_event.go index bd58fc708..3a0dda38b 100644 --- a/lib/cdc/util/relational_event.go +++ b/lib/cdc/util/relational_event.go @@ -108,6 +108,8 @@ func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConf } retMap[constants.DeleteColumnMarker] = false retMap[constants.OnlySetDeleteColumnMarker] = false + default: + return nil, fmt.Errorf("unknown operation %q", s.Operation()) } if tc.IncludeArtieUpdatedAt { From b4b60ba18d49c6a8592ae252aa084bb559ced195 Mon Sep 17 00:00:00 2001 From: Robin Tang <rtang.cs@gmail.com> Date: Thu, 17 Oct 2024 09:00:07 -0700 Subject: [PATCH 3/3] Clean up imports. --- lib/cdc/event.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/cdc/event.go b/lib/cdc/event.go index db6c43bbe..b146948c1 100644 --- a/lib/cdc/event.go +++ b/lib/cdc/event.go @@ -3,11 +3,9 @@ package cdc import ( "time" - "github.com/artie-labs/transfer/lib/typing/columns" - - "github.com/artie-labs/transfer/lib/typing" - "github.com/artie-labs/transfer/lib/kafkalib" + "github.com/artie-labs/transfer/lib/typing" + "github.com/artie-labs/transfer/lib/typing/columns" ) type Format interface {