我有一个简单的avro架构,如下所示:
{
"type": "record",
"name": "transaction",
"namespace": "com.mycompany",
"doc": "Transaction records",
"fields": [
{
"name": "version",
"type": "int",
"default": 1,
"doc": "version the class"
},
{
"name": "eventType",
"type": "string",
"default": "saleTransaction",
"doc": "event type"
},
{
"name": "writeTimestamp",
"type": "org.joda.time.DateTime",
"doc": "Timestamp when this event was written to the stream"
},
{
"name": "originatingClient",
"type": "string",
"doc": "identifier of the originating client"
}
}
当我使用avro-maven-plugin编译它时,我收到以下错误:
错误]无法执行目标
目标的执行事务架构 org.apache.avro:avro-maven-plugin:1.8.0:架构失败: " org.joda.time.DateTime"不是定义的名称。的类型 " writeTimestamp"字段必须是已定义的名称或{" type":...} 表达。 - > [帮助1]
如何让它发挥作用?
答案 0 :(得分:1)
目前在Avro中没有日期支持,您需要将时间存储为长时间。并且不支持自定义类型,因为这意味着支持该类型的avro序列化和反序列化。