在 Apache NiFi 中定义 Apache Avro Schema 全名
Defining Apache Avro Schema fullname in Apache NiFi
使用 NiFi 1.7.1(使用 Java Avro 1.8.1)并在 AvroSchemaRegistry 中,我试图定义一个具有字段 name
和 app.name
在顶层。根据 Avro 文档 [1],我假设我可以像正常 "name": "app.name"
一样定义全名,但我遇到了错误 Illegal character in: app.name
。的确,全名的名称部分不允许使用点,但根据文档:"If the name specified contains a dot, then it is assumed to be a fullname..."
然后我尝试使用名称空间字段。使用以下架构:
{
"type": "record",
"name": "nameRecord",
"fields": [
{
"type": [
"string",
"null"
],
"name": "name"
},
{
"type": [
"string",
"null"
],
"namespace": "app",
"name": "name"
}
]
}
我遇到了这个错误:Duplicate field name in record nameRecord: name type:UNION pos:1 and name type:UNION pos:0
最终,我希望能够为这样的记录定义一个模式(在 JSON 中):
{
"name": "Joe",
"app.name": "NiFi"
}
根据the docs,命名空间仅支持记录、枚举和固定类型,其他字段必须遵守"regular"命名约定,其中句号(.)不是有效字符。
但是从 NiFi 1.5.0 开始(通过 NIFI-4612), you could specify the schema in an AvroSchemaRegistry,并将 "Validate Field Names" 设置为 false。这应该允许您绕过字段名称为 app.name
的限制。
使用 NiFi 1.7.1(使用 Java Avro 1.8.1)并在 AvroSchemaRegistry 中,我试图定义一个具有字段 name
和 app.name
在顶层。根据 Avro 文档 [1],我假设我可以像正常 "name": "app.name"
一样定义全名,但我遇到了错误 Illegal character in: app.name
。的确,全名的名称部分不允许使用点,但根据文档:"If the name specified contains a dot, then it is assumed to be a fullname..."
然后我尝试使用名称空间字段。使用以下架构:
{
"type": "record",
"name": "nameRecord",
"fields": [
{
"type": [
"string",
"null"
],
"name": "name"
},
{
"type": [
"string",
"null"
],
"namespace": "app",
"name": "name"
}
]
}
我遇到了这个错误:Duplicate field name in record nameRecord: name type:UNION pos:1 and name type:UNION pos:0
最终,我希望能够为这样的记录定义一个模式(在 JSON 中):
{
"name": "Joe",
"app.name": "NiFi"
}
根据the docs,命名空间仅支持记录、枚举和固定类型,其他字段必须遵守"regular"命名约定,其中句号(.)不是有效字符。
但是从 NiFi 1.5.0 开始(通过 NIFI-4612), you could specify the schema in an AvroSchemaRegistry,并将 "Validate Field Names" 设置为 false。这应该允许您绕过字段名称为 app.name
的限制。