我使用kafka流将xml消息转换为avro格式。我想知道,在我的avro模式中使用union type时,是否可以保留union记录的字段名,如下例所示,以便在avro消息中使用“record1”或“record2”,而不是名称“main\u record”,具体取决于我接收的输入数据:
{
"namespace": "proj.avro",
"protocol": "app_messages",
"doc" : "application messages",
"name": "myRecord",
"type" : "record",
"fields": [
{
"name": "main_record",
"type": [
{
"name": "record1",
"type" : "record",
"fields":
[
{
"name" : "request_id",
"type" : "int"
},
{
"name" : "message_type",
"type" : "int"
},
{
"name" : "users",
"type" : "string"
}
]
},
{
"name" : "record2",
"type" : "record",
"fields" :
[
{
"name" : "request_id",
"type" : "int"
},
{
"name" : "response_code",
"type" : "string"
},
{
"name" : "response_count",
"type" : "int"
},
{
"name" : "reason_code",
"type" : "string"
}
]
}
]
}
]
}
暂无答案!
目前还没有任何答案,快来回答吧!