[英]How do I get the avro code generator to use a different type, other than the predefined primitive and complex types in schema?
I have a simple avro schema that looks like this: 我有一个简单的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"
}
}
When I compile it using avro-maven-plugin, I get the following error: 使用avro-maven-plugin进行编译时,出现以下错误:
ERROR] Failed to execute goal
错误]无法执行目标
Execution transaction-schemas of goal org.apache.avro:avro-maven-plugin:1.8.0:schema failed: "org.joda.time.DateTime" is not a defined name.
目标org.apache.avro:avro-maven-plugin:1.8.0:schema的执行事务模式失败:“ org.joda.time.DateTime”不是定义的名称。 The type of the "writeTimestamp" field must be a defined name or a {"type": ...} expression.
“ writeTimestamp”字段的类型必须是定义的名称或{“ type”:...}表达式。 -> [Help 1]
-> [帮助1]
How do I get this to work? 我该如何工作?
There is no date support as of now in Avro, you would have to store the time as a long. 到目前为止,Avro中没有日期支持,您必须将时间存储很长时间。 And there is no support for custom types, as that would mean to support avro serialization and deserialization of that type.
而且不支持自定义类型,因为这将意味着支持该类型的avro序列化和反序列化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.