Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how we qualify a deleted row in relational_event #965

Merged
merged 3 commits into from
Oct 17, 2024
Merged
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
6 changes: 2 additions & 4 deletions lib/cdc/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions lib/cdc/util/relational_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,14 +101,15 @@ 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
}
retMap[constants.DeleteColumnMarker] = false
retMap[constants.OnlySetDeleteColumnMarker] = false
default:
return nil, fmt.Errorf("unknown operation %q", s.Operation())
}

if tc.IncludeArtieUpdatedAt {
Expand Down
Loading