Repository navigation
CASSANALYTICS-216: CDC Avro schema conversion fails for UDTs with quoted names containing characters invalid in Avro - #255
Conversation
shruti-p-s
left a comment
There was a problem hiding this comment.
Just a few comments, looks great otherwise, thank you!
| if (totalSize + value.remaining() > truncateThreshold) | ||
| { | ||
| truncatedFields.add(field.columnName); | ||
| truncatedFields.add(column.name()); |
There was a problem hiding this comment.
truncatedFields gets the Avro name here, but updateFields still carries the CQL name. Should updateFields use the Avro name too?
| CqlField.CqlType type = typeLookup.apply(KeyspaceTypeKey.of(event.keyspace, field.columnType)); | ||
| Object javaValue = JavaTypeConverter.deserialize(type, fieldValue); | ||
| update.put(field.columnName, AvroDataUtils.toAvro(javaValue, column.schema())); | ||
| update.put(column.name(), AvroDataUtils.toAvro(javaValue, column.schema())); |
There was a problem hiding this comment.
I think field has the same split as the truncatedFields.
| map.forEach((key, value) -> { | ||
| final String fieldName = key.toString(); // UDT key should always be the fieldName of type String | ||
| udtEntry.put(fieldName, toAvro(value, unwrapped.getField(fieldName).schema())); | ||
| Schema.Field udtField = AvroSchemas.field(unwrapped, fieldName); |
There was a problem hiding this comment.
I think the read side has the same split: UdtConversion returns Avro-named keys, but toAvro now expects CQL field names here.
| if (column.isPrimaryKeyColumn()) | ||
| { | ||
| primaryKeys.add(column.name.toString()); | ||
| primaryKeys.add(avroName); |
There was a problem hiding this comment.
Building on Shruti's comment on truncatedFields, the key lists have the same split. primary_keys, partition_keys, clustering_keys and static_columns now hold Avro names, while update_fields still holds CQL names. Whichever way we resolve it, could we use one convention across all of these lists and document it?
|
Thanks Bernardo, sanitizing at schema-build time and keeping the original in My main concern is the Would a reversible escape be simpler? Debezium's Related to this, the CQL-to-Avro mapping happens in a few places that don't share a call:
It might be worth having one place that owns the name mapping, plus a shared |
|
Thanks @bbotella for addressing comments, l reran CI let's merge the PR once the CI is green. Also please post Circle CI link |
fa2e44f to
32bd39d
Compare
32bd39d to
4dec299
Compare
Patch by Bernardo Botella; Reviewed by Jyothsna Konisa for CASSANALYTICS-216