gpt4 book ai didi

schema - 具有嵌套模式数组的 avro

转载 作者:行者123 更新时间:2023-12-05 07:48:55 29 4
gpt4 key购买 nike

我试图在 apache avro 中表示一个“订单”及其相关条目。请参阅下面的架构。尝试在 Eclipse 中构建它时出现以下错误。感谢您的帮助。

[ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.8.1:schema (default) on project avrosample: Execution default of goal org.apache.avro:avro-maven-plugin:1.8.1:schema failed: Undefined name: "com.company.domain.entry" -> [Help 1]

**Schema For Entry:**
{"namespace": "com.company.domain",
"type": "record",
"name": "entry",
"fields": [
{"name": "id", "type": "long"},
{"name": "description", "type": "string"},
{"name": "quantity", "type: “int”}

]
}

**Schema for Order:**
{"namespace": "com.company.domain",
"type": "record",
"name": "order",
"fields": [
{"name": "id", "type": "long"},
{"name": "date", "type": "long"},
{"name": "entries", "type": {"items": "array", "items": "com.company.domain.entry"} }}

]
}

最佳答案

如果我没记错的话,您不能以这种方式将 Entry-schema 链接到 Order-schema。你为什么不使用 Order 的联合模式呢?像这样:

{
"type": "record",
"name": "Order",
"namespace": "com.company.domain",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "date",
"type": "long"
},
{
"name": "entries",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "Entry",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "description",
"type": "string"
},
{
"name": "quantity",
"type": "int"
}
]
},
"java-class": "java.util.List"
}
}
]
}

关于schema - 具有嵌套模式数组的 avro,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37950803/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com