Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ private List<RichCdcMultiplexRecord> handleOperation(

switch (op) {
case OP_INSERT:
records.add(processRecord(fullDocument, RowKind.INSERT));
RichCdcMultiplexRecord insertRecord = processRecord(fullDocument, RowKind.INSERT);
if (insertRecord != null) {
records.add(insertRecord);
}
break;
case OP_REPLACE:
case OP_UPDATE:
// Before version 6.0 of MongoDB, it was not possible to obtain 'Update Before'
// information. Therefore, data is first deleted using the primary key '_id', and
// then inserted.
records.add(processRecord(documentKey, RowKind.DELETE));
records.add(processRecord(fullDocument, RowKind.INSERT));
RichCdcMultiplexRecord updateRecord = processRecord(fullDocument, RowKind.INSERT);
if (updateRecord != null) {
records.add(updateRecord);
}
break;
case OP_DELETE:
records.add(processRecord(documentKey, RowKind.DELETE));
Expand All @@ -125,6 +131,9 @@ private RichCdcMultiplexRecord processRecord(JsonNode fullDocument, RowKind rowK
CdcSchema.Builder schemaBuilder = CdcSchema.newBuilder();
Map<String, String> record =
getExtractRow(fullDocument, schemaBuilder, computedColumns, mongodbConfig);
if (record == null) {
return null;
}
schemaBuilder.primaryKey(extractPrimaryKeys());
return new RichCdcMultiplexRecord(
databaseName, collection, schemaBuilder.build(), new CdcRecord(rowKind, record));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ default Map<String, String> getExtractRow(
List<ComputedColumn> computedColumns,
Configuration mongodbConfig)
throws JsonProcessingException {
if (jsonNode == null || jsonNode.isNull()) {
return null;
}
SchemaAcquisitionMode mode =
SchemaAcquisitionMode.valueOf(mongodbConfig.get(START_MODE).toUpperCase());
ObjectNode objectNode =
Expand Down
Loading