我正在尝试使用这种Avro模式
{
"type": "record",
"name": "ComplianceEntity",
"namespace": "com.linkedin.events.metadata",
"fields": [
{
"name": "fieldPath",
"type": "string"
},
{
"name": "complianceDataType",
"type": {
"type": "enum",
"name": "ComplianceDataType",
"symbols": [
"NONE",
"MEMBER_ID"
],
"symbolDocs": {
"NONE": "None of the following types apply",
"MEMBER_ID": "ID for LinkedIn members"
}
}
},
{
"name": "complianceDataTypeUrn",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "fieldFormat",
"type": [
"null",
{
"type": "enum",
"name": "FieldFormat",
"symbols": [
"NUMERIC"
],
"symbolDocs": {
"NUMERIC": "Numerical format, 12345"
},
"doc": "The field format"
}
]
},
{
"name": "securityClassification",
"type": "SecurityClassification"
},
{
"name": "valuePattern",
"default": null,
"type": [
"null",
"string"
]
}
]
}
使用avro工具生成和avro文件:
java -jar ./avro-tools-1.8.2.jar compile schema ComplianceEntity.avsc .
但是我收到以下错误消息:
线程“主”中的异常org.apache.avro.SchemaParseException:“ SecurityClassification”不是已定义的名称。 “ securityClassification”字段的类型必须是定义的名称或{“ type”:...}表达式。
谁能说出,为什么没有将SecurityClassification标识为已定义名称?
答案 0 :(得分:0)
您将其用作字段的类型,但是没有像complianceDataType
那样正确地定义它,这就是为什么您遇到avro异常的原因
{
"name": "securityClassification",
"type": "SecurityClassification"
}
请确保如果您具有多个模式,请通过所有这些模式,尤其是依赖项模式。 AVRO 1.5.3 https://issues.apache.org/jira/browse/AVRO-877支持此功能。
java -jar ./avro-tools-1.8.2.jar compile schema SecurityClassification.avsc ComplianceEntity.avsc .