gpt4 book ai didi

nested - Avro 架构中嵌套记录的默认值

转载 作者:行者123 更新时间:2023-12-04 01:56:34 26 4
gpt4 key购买 nike

这个问题/答案( How to nest records in an Avro schema? )澄清了如何嵌套复杂类型(在这种情况下为记录)。但是,我想知道是否有人知道如何为记录类型设置默认值。在上述问题中显示的示例中,我遇到错误,地址丢失,我更喜欢 avro 将其默认为空字典或至少为空字符串 - 而不是我必须将其默认为进步。

最佳答案

您只能将空值作为 AVRO 中嵌套对象的默认值。这是默认模式 null 的样子值(value)

{
"name": "person",
"type": "record",
"fields": [
{"name": "firstname", "type": "string"},
{"name": "lastname", "type": "string"},
{
"name": "address",
"type": ["null" , {
"type" : "record",
"name" : "AddressUSRecord",
"fields" : [
{"name": "streetaddress", "type": "string"},
{"name": "city", "type": "string"}
]
}],
"default": null
}
]
}

关于nested - Avro 架构中嵌套记录的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50108160/

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