Skip to content

Commit

Permalink
DBZ-7554 AvroConverter fails to parse events on tables with multiple …
Browse files Browse the repository at this point in the history
…columns

Adjust schema names for cells to be unique. Avro uses these names to
identify sub schema declarations and will not redefine a sub schema that
was already detected. In this case, if we have cells with multiple
types, debezium will fail to serialize the event, since the stored avro
schema does not match the cells.
  • Loading branch information
schampilomatis committed Feb 22, 2024
1 parent 649b861 commit 17c12a3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static Schema rowSchema(List<String> columnNames, List<DataType> columnsTypes) {
for (int i = 0; i < columnNames.size(); i++) {
Schema valueSchema = CassandraTypeDeserializer.getSchemaBuilder(columnsTypes.get(i)).build();
String columnName = columnNames.get(i);
Schema optionalCellSchema = CellData.cellSchema(valueSchema, true);
Schema optionalCellSchema = CellData.cellSchema(columnName, valueSchema, true);
if (optionalCellSchema != null) {
schemaBuilder.field(columnName, optionalCellSchema);
}
Expand Down Expand Up @@ -296,13 +296,13 @@ public Struct record(Schema schema) {
}
}

static Schema cellSchema(Schema columnSchema, boolean optional) {
static Schema cellSchema(String columnName, Schema columnSchema, boolean optional) {
if (columnSchema == null) {
return null;
}

SchemaBuilder schemaBuilder = SchemaBuilder.struct()
.name(CELL_SCHEMA_NAME)
.name(columnName)
.version(CELL_SCHEMA_VERSION)
.field(CELL_VALUE_KEY, columnSchema)
.field(CELL_DELETION_TS_KEY, OPTIONAL_INT64_SCHEMA)
Expand Down

0 comments on commit 17c12a3

Please sign in to comment.