public class DebeziumJsonRecordParser extends AbstractJsonRecordParser
DebeziumRecordParser
class extends the abstract AbstractJsonRecordParser
and
is designed to parse records from Debezium's JSON change data capture (CDC) format. Debezium is a
CDC solution for MySQL databases that captures row-level changes to database tables and outputs
them in JSON format. This parser extracts relevant information from the Debezium-JSON format and
converts it into a list of RichCdcMultiplexRecord
objects.
The class supports various database operations such as INSERT, UPDATE, DELETE, and READ
(snapshot reads), and creates corresponding RichCdcMultiplexRecord
objects to represent
these changes.
Validation is performed to ensure that the JSON records contain all necessary fields, including the 'before' and 'after' states for UPDATE operations, and the class also supports schema extraction for the Kafka topic. Debezium's specific fields such as 'source', 'op' for operation type, and primary key field names are used to construct the details of each record event.
root
computedColumns, FIELD_DATABASE, FIELD_TABLE, typeMapping
Constructor and Description |
---|
DebeziumJsonRecordParser(TypeMapping typeMapping,
List<ComputedColumn> computedColumns) |
Modifier and Type | Method and Description |
---|---|
protected String |
dataField() |
List<RichCdcMultiplexRecord> |
extractRecords() |
protected Map<String,String> |
extractRowData(org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode record,
RowType.Builder rowTypeBuilder) |
protected String |
format() |
protected String |
getDatabaseName() |
protected String |
getTableName() |
protected String |
primaryField() |
protected void |
setRoot(CdcSourceRecord record) |
checkNotNull, checkNotNull, extractPrimaryKeys, fillDefaultTypes, getAndCheck, getAndCheck, mergeOldRecord, processRecord
buildSchema, createRecord, evalComputedColumns, flatMap, isDDL
public DebeziumJsonRecordParser(TypeMapping typeMapping, List<ComputedColumn> computedColumns)
public List<RichCdcMultiplexRecord> extractRecords()
extractRecords
in class AbstractRecordParser
protected void setRoot(CdcSourceRecord record)
setRoot
in class AbstractJsonRecordParser
protected Map<String,String> extractRowData(org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode record, RowType.Builder rowTypeBuilder)
extractRowData
in class AbstractJsonRecordParser
protected String primaryField()
primaryField
in class AbstractJsonRecordParser
protected String dataField()
dataField
in class AbstractJsonRecordParser
@Nullable protected String getTableName()
getTableName
in class AbstractJsonRecordParser
@Nullable protected String getDatabaseName()
getDatabaseName
in class AbstractJsonRecordParser
protected String format()
format
in class AbstractRecordParser
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.