Skip to content

Commit

Permalink
source-mongodb: merge deletion events
Browse files Browse the repository at this point in the history
This adds the (conditional) reduction strategy to deletion events to merge them
into existing documents. For materializations using soft deletions, this will
have the effect of only updating the `_meta/op` column to `"d"` for the
materialized row, instead of removing all of the values from other non-key
columns.

This will make soft deletions for MongoDB-captured collections work the same way
as other CDC connectors, while still using the top-level "last write wins"
reductions strategy for other events, most notably updates, where we don't emit
explicit `null` values for removed fields (yet).
  • Loading branch information
williamhbaker committed Sep 13, 2024
1 parent 210aa06 commit 0756999
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions source-mongodb/.snapshots/TestDiscover
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Binding 0:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -106,7 +106,7 @@ Binding 1:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down
12 changes: 6 additions & 6 deletions source-mongodb/.snapshots/TestDiscoverAllDatabases
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Binding 0:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -106,7 +106,7 @@ Binding 1:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -192,7 +192,7 @@ Binding 2:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -278,7 +278,7 @@ Binding 3:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -364,7 +364,7 @@ Binding 4:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -450,7 +450,7 @@ Binding 5:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down
8 changes: 4 additions & 4 deletions source-mongodb/.snapshots/TestDiscoverMultipleDatabases
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Binding 0:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -106,7 +106,7 @@ Binding 1:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -192,7 +192,7 @@ Binding 2:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down Expand Up @@ -278,7 +278,7 @@ Binding 3:
"then": {
"reduce": {
"delete": true,
"strategy": "lastWriteWins"
"strategy": "merge"
}
},
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion source-mongodb/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func generateMinimalSchema() json.RawMessage {
Then: &jsonschema.Schema{
Extras: map[string]interface{}{
"reduce": map[string]interface{}{
"strategy": "lastWriteWins",
"strategy": "merge",
"delete": true,
},
},
Expand Down

0 comments on commit 0756999

Please sign in to comment.