shruti-p-s commented on code in PR #255:
URL: 
https://github.com/apache/cassandra-analytics/pull/255#discussion_r4487273256


##########
cassandra-analytics-cdc-codec/src/main/java/org/apache/cassandra/cdc/avro/CdcEventUtils.java:
##########
@@ -303,28 +303,28 @@ public static UpdatedEvent getUpdatedEvent(CdcEvent event,
 
         for (Value field : CdcEventUtils.updatedFields(event))
         {
+            Schema.Field column = AvroSchemas.field(tableSchema, 
field.columnName);
+            Preconditions.checkNotNull(column,
+                                       "Encountered an unknown field during 
event encoding. " +
+                                       "Field: %s. Avro schema: %s", 
field.columnName, tableSchema.getFullName());
             ByteBuffer value = field.getValue();
             if (value == null) // the field is deleted
             {
-                update.put(field.columnName, null);
+                update.put(column.name(), null);
                 continue;
             }
 
             if (totalSize + value.remaining() > truncateThreshold)
             {
-                truncatedFields.add(field.columnName);
+                truncatedFields.add(column.name());

Review Comment:
   `truncatedFields` gets the Avro name here, but `updateFields` still carries 
the CQL name. Should `updateFields` use the Avro name too?
   



##########
cassandra-analytics-cdc-codec/src/main/java/org/apache/cassandra/cdc/avro/AvroBaseRecordTransformer.java:
##########
@@ -71,15 +71,15 @@ public GenericData.Record transform(CdcEvent event)
             ByteBuffer fieldValue = field.getValue();
             Preconditions.checkNotNull(fieldValue, "Field value of column %s 
should not be null for range predicate", field.columnName);
             Schema tableSchema = store.getSchema(event.keyspace + '.' + 
event.table, null);
-            Schema.Field column = tableSchema.getField(field.columnName);
+            Schema.Field column = AvroSchemas.field(tableSchema, 
field.columnName);
             Preconditions.checkNotNull(column,
                                        "Encountered an unknown field during 
range predicate encoding. " +
                                        "Field: %s. Avro schema: %s", 
field.columnName, tableSchema.getFullName());
 
             GenericData.Record update = new GenericData.Record(tableSchema);
             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()));

Review Comment:
   I think `value` has the same split as the `truncatedFields`.



##########
cassandra-analytics-cdc-codec/src/main/java/org/apache/cassandra/cdc/avro/AvroDataUtils.java:
##########
@@ -134,7 +134,8 @@ else if (cassandraValue instanceof Map)
                 GenericData.Record udtEntry = new 
GenericData.Record(unwrapped);
                 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);

Review Comment:
   I think the read side has the same split: `UdtConversion` returns Avro-named 
keys, but `toAvro` now expects CQL field names here.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to