【发布时间】:2019-09-17 13:33:02
【问题描述】:
我正在尝试为下面的 json 创建 avro 架构
{
"id": "TEST",
"status": "status",
"timestamp": "2019-01-01T00:00:22-03:00",
"comment": "add comments or replace it with adSummary data",
"error": {
"code": "ER1212132",
"msg": "error message"
}
}
错误对象是可选的,它可以是 “错误” :{} 下面是没有默认值的avro架构
{
"type" : "record",
"name" : "Order",
"fields" : [ {
"name" : "id",
"type" : "string"
}, {
"name" : "status",
"type" : "string"
}, {
"name" : "timestamp",
"type" : "string"
}, {
"name" : "comment",
"type" : ["null","string"],
"default": null
}, {
"name" : "error",
"type" : {
"type" : "record",
"name" : "error",
"fields" : [ {
"name" : "code",
"type" : "string"
}, {
"name" : "msg",
"type" : "string"
} ]
}
} ]
}
如何为 json 中的错误字段添加默认值 {}。
【问题讨论】:
标签: avro spark-avro avro-tools