问题
I have deployed a sample from confluent https://github.com/confluentinc/kafka-connect-insert-uuid for adding simple UUID field but I am getting an error that it requires struct. I am applying this within Debezium MySQLConnector
Only Struct objects supported for [adding UUID to record], found:
java.lang.String\n\tat org.apache.kafka.connect.transforms.util.Requirements.requireStruct(Requirements.java:52)
What is a minimalist applyWithSchema method that just returns the record as is? I am trying to debug and need a HelloWorld SMT without any errors that have to apply methods including applyWithSchema
I think this is probably most simple for the application but need for applyWithSchema
Override
public R apply(R record) {
return record.newRecord(
record.topic(), record.kafkaPartition(),
record.keySchema(), record.key(),
record.valueSchema(), record.value(),
record.timestamp()
);
}
Override
public R applyWithSchema(R record) {
// what is minimal transform here??
}
I just need these functions to run without error now, as I am making a change to record.headers().add() only.
Here is the applyWithSchema method that gives the error:
private R applyWithSchema(R record) {
// FAILS HERE!
final Struct value = requireStruct(operatingValue(record), PURPOSE);
Schema updatedSchema = schemaUpdateCache.get(value.schema());
if(updatedSchema == null) {
updatedSchema = makeUpdatedSchema(value.schema());
final Struct updatedValue = new Struct(updatedSchema);
for (Field field : value.schema().fields()) {
// updatedValue.put(field.name(), value.get(field));
}
//updatedValue.put(fieldName, getRandomUuid());
return newRecord(record, updatedSchema, updatedValue);
}
来源:https://stackoverflow.com/questions/63311462/kafka-connect-smt-applywithschema-requires-struct-error