英文:
PubSub Avro schema with JSON array throws Invalid schema definition error
问题
我正在设置一个发布/订阅主题来接收一些JSON数据。JSON数据中的一个字段是一个字符串数组,如下所示:
{
...
"Tags": ["2333TAG"],
...
}
我尝试按照Avro 1.11规范定义模式:
{
"type": "record",
"name": "Avro",
"fields": [
...
{
"name": "Tags",
"type": "array",
"items": "string",
"default": []
},
...
]
}
但是当我尝试验证定义时,我收到错误消息:无效的模式定义:引用节点未引用先前声明的类型:array
你知道我可能做错了什么吗?我已经确认这是模式中引发错误的字段。
英文:
I'm setting up a pub/sub topic to receive some JSON data. One of the fields in the JSON data is an array of strings, like so:
{
...
"Tags": ["2333TAG"],
...
}
I've tried defining the schema as per the Avro 1.11 spec:
{
"type": "record",
"name": "Avro",
"fields": [
...
{
"name": "Tags",
"type": "array",
"items": "string",
"default": []
},
...
]
}
But when I try to validate the definition, I get the error: Invalid schema definition: Reference node does not refer to previously declared type: array
Any idea of what I might be doing wrong? I have verified that this is the field in the schema that's throwing the error.
答案1
得分: 2
Avro 需要使用嵌套类型来声明一个 array
:
{
"type": "record",
"name": "Avro",
"fields": [
...
{
"name": "Tags",
"type": {
"type": "array",
"items": "string",
"default": []
}
}
...
]
}
英文:
Avro requires a nested type for declaring an array
:
{
"type": "record",
"name": "Avro",
"fields": [
...
{
"name": "Tags",
"type": {
"type": "array",
"items": "string",
"default": []
}
}
...
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论