Kee*_*gan 14
默认情况下,Avro中都需要所有字段.正如官方文档中所提到的,如果你想创建一些可选的东西,你必须通过将它的类型联合起来使它成为可空的null,就像这样
{ "namespace": "example.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}
]
}
Run Code Online (Sandbox Code Playgroud)
在此示例中,name是必需的,favorite_number并且favorite_color是可选的.我建议您花更多时间阅读文档.
| 归档时间: |
|
| 查看次数: |
2683 次 |
| 最近记录: |