I have a dataframe that I need to write to Kafka.
I have the avro schema defined, similar to this:
{
"namespace": "my.name.space",
"type": "record",
"name": "MyClass",
"fields": [
{"name": "id", "type": "string"},
{"name": "parameter1", "type": "string"},
{"name": "parameter2", "type": "string"},
...
]
}
and it's auto-generated to java bean. It's something similar to this:
public class MyClass extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
String id;
String parameter1;
String parameter2;
...
}
I found that to write in avro format there is only to_avro method that takes a column.
So my question, is there a way to force writing to Kafka in Avro format in this defined schema?