avro - 定义 Avro 模式
问题描述
我有一些像这样的 avro 数据,它们打印在终端中。
{"cust_status_id":0, "cust_status_description":{"string":" Approved"}}
我创建的 avro 模式就像
{
"namespace": "com.thp.report.model",
"type": "record",
"name": "PraStatusMaster",
"fields": [
{
"name": "cust_status_id",
"type": "int"
},
{
"name": "cust_status_description",
"type": "string",
"avro.java.string": "String"
}
]
}
架构是否正确?
解决方案
您的 json 的正确架构如下:
{
"name": "PraStatusMaster",
"type": "record",
"namespace": "com.thp.report.model",
"fields": [
{
"name": "cust_status_id",
"type": "int"
},
{
"name": "cust_status_description",
"type": {
"name": "cust_status_description",
"type": "record",
"fields": [
{
"name": "string",
"type": "string"
}
]
}
}
]
}
推荐阅读
- node.js - 将 .htacees 指向使用 SSL 配置的节点服务器
- composer-php - Symfony 5 和 Sonata Admin Bundle 兼容性?
- java - 在处理过程中控制水滴数组的 Y 值
- ios - 具有动态高度的 ReactiveTableViewCell 反对单元重用:如何避免陷入无限循环?
- io - 我如何最惯用地在 Rust 中为 no_std 平台编写异步 IO 库?
- python - 模型拟合和交叉验证
- laravel - Laravel 从 5.8 升级到 laravel 6 - 调用未定义的方法 Laravel\Cashier\Cashier::useCurrency()
- sql - 如何检查时间段是否被 SQL 中较小的时间段完全覆盖?
- scala - 使用 Akka Graphs 实现简单的架构
- python - 如何在 Python 中将文本打印到打印机而无需在第一页(或每页)上打印文件名?