本文介绍了为时间戳记录创建正确的avro模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道以这种格式进行json到avro转换的正确avro模式是什么:
I would like to know what the proper avro schema would be for some json to avro conversion that is in this format:
{"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类型.
It was a silly mistake...obviously I was storing the timestamp value as a string so the avro schema needed a string instead of long for type.
即.
{ "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!
更多推荐
为时间戳记录创建正确的avro模式
发布评论