我想拥有一个名为validExtensions的字段的avro架构。如何让validExtensions接受枚举扩展名列表?
我在枚举中创建了一个可接受的扩展名列表:
{
"type":"enum",
"name":"extensions",
"symbols": [".zip",".txt",".csv",".pdf",".xls",".xlsx"]
}
但我似乎无法找到一种方法来在扩展中使用一个接受枚举值数组的字段。例如,json输出将是:
{
"data":{
"validExtensions": [".csv", ".xls"],
"fileName": "testing.csv"
}
}
这是我已经尝试过的但是不起作用:
{
"type":"record",
"name":"data",
"fields": [
{
"name":"validExtensions",
"type":"array",
"items": {
"extensions"
}
}
]
}
答案 0 :(得分:1)
找到适用于枚举数组的内容:
{
"type":"enum",
"name":"Extensions",
"symbols": [".zip",".txt",".csv"]
}
{
"type":"record",
"name":"data",
"fields": [
{
"name": "key",
"type": "string"
{
"name":"validExtensions",
"type":{"type":"array", "items":"Extensions"}
}
]
}