Я пытаюсь создать данные avro в kafka с помощью GenericData.Record, но получаю следующее исключение:
Исключение в потоке "main" org.apache.avro.AvroRuntimeException: недопустимое поле схемы: emailAddresses.email
Вот моя схема:
{
"namespace": "com.cloudurable.User",
"type": "record",
"name": "User",
"fields": [
{"name": "id", "type": "int", "default" : 0},
{"name": "fname", "type": "string", "default" : "EMPTY"},
{"name": "lname", "type": "string", "default" : "EMPTY"},
{"name": "phone_number", "type": "string", "default" : "EMPTY"},
{"name": "age", "type": "int", "default" : 0},
{
"name": "emailAddresses",
"type": {
"type": "record",
"name": "EmailAddress",
"fields": [
{
"name": "email",
"type": "string",
"default" : "EMPTY"
},
{
"name": "address",
"type": "boolean",
"default": false
}
]
}
}
]
}
Мой код Java выглядит следующим образом:
GenericData.Record avroRecord = new GenericData.Record(SchemaRegstryClient.getLatestSchema("test2"));
System.out.println(avroRecord.getSchema().getFields());
avroRecord.put("id", i);
avroRecord.put("fName", "Sumit" + i);
avroRecord.put("lName", "Gupta " +i);
avroRecord.put("phone_number", "98911 " +i);
avroRecord.put("age", i);
avroRecord.put("emailAddresses.email", "[email protected]");
avroRecord.put("emailAddresses.address", true);
Кто-нибудь знает, как я могу поместить вложенное значение в запись avro?