我想知道对于这种格式的 json 到 avro 转换,正确的 avro 模式是什么:
{"entryDate": "2018-01-26T12:00:40.930"}
我的架构:
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : "long",
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
我不断得到
`'Cannot convert field entryDate: Cannot resolve union:
"2018-01-26T12:00:40.930"
not in
["null",{"type":"long","logicalType":"timestamp-millis"}]'`
这是一个愚蠢的错误...显然我将时间戳值存储为字符串,因此 avro 模式需要一个字符串而不是 long 类型。
ie.
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : `**"long"**`,
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
应该
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : `**"string"**`,
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
doh!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)