koa*_*421 7 json data-conversion avro apache-nifi
我想知道适当的avro架构对于这种格式的一些json到avro转换是什么:
{"entryDate": "2018-01-26T12:00:40.930"}
Run Code Online (Sandbox Code Playgroud)
我的架构:
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : "long",
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
Run Code Online (Sandbox Code Playgroud)
我一直在
`'Cannot convert field entryDate: Cannot resolve union:
"2018-01-26T12:00:40.930"
not in
["null",{"type":"long","logicalType":"timestamp-millis"}]'`
Run Code Online (Sandbox Code Playgroud)
这是一个愚蠢的错误......显然我将时间戳值存储为字符串,因此avro架构需要一个字符串而不是long类型.
即.
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : `**"long"**`,
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
Run Code Online (Sandbox Code Playgroud)
应该
{
"type" : "record",
"name" : "schema",
"fields" : [{
"name" : "entryDate",
"type" : ["null", {
"type" : `**"string"**`,
"logicalType" : "timestamp-micros"
}],
"default" : null
}]
}
Run Code Online (Sandbox Code Playgroud)
卫生署!
归档时间: |
|
查看次数: |
6957 次 |
最近记录: |