Change/Update NiFi 模式文本中的字段名称 属性 跨各种并行流
Change/Update Field name in the NiFi Schema Text property Across various parallel flows
我有几个相同的并行流程(如屏幕截图所示)。我在每个相同的流程和记录 Reader 中都有 convertRecord,我使用 "Schema Text Field Property" 作为访问策略并指定了 "Schema text"。例如:
{
"type": "record",
"name": "AVLRecord0",
"fields" : [
{"name": "TimeOfDay", "type": "string", "logicalType":"timestamp-millis"},
{"name":"Field1", "type": "double"},
{"name":"Field2", "type": "double"},
{"name":"Field3", "type": "double"},
{"name": "Filename", "type": "string"}
]
}
假设我在各种并行流 ConvertRecord 中使用了上述模式,现在我想将一个字段名称从 Field 更新为 Field_Name 那么有没有我可以一次性完成所有转换记录模式文本的方法吗?
如果我想 change/update 模式文本中的字段之一,我是否必须手动 change/Update 每个处理器中的字段名称?或者有一种全局方式可以更改我拥有的所有并行流中的字段名称?
有什么方法可以一次性更新跨各种处理器的模式文本?
非常感谢任何帮助!谢谢
由于您正在使用 Schema Text Field Property
,因此您需要手动更改 所有 ConvertRecord 处理器。
试试这个方法:
在 ConvertRecord 处理器中使用 Schema Access Strategy as
Use Schema Name Property
然后设置 AvroSchemaRegistry 并通过添加新的 属性
来定义您的架构
我已将 sch
添加为 schema.name 并定义了 avro 架构。
在 GetFile 处理器使用 UpdateAttribute
处理器后,将 schema.name
属性(例如:值为 sch)添加到流文件。
- 现在在 reader 控制器服务中使用模式访问策略作为已经设置的
Use Schema Name Property and Schema Registry as
AvroSchemaRegistry`。
通过这种方式,我们没有在所有 ConvertRecord
[=55= 上定义模式 ] 处理器,我们指的是 在 AvroSchemaRegistry
中定义的相同模式 以防万一,如果您想更改一个字段名称,很容易进入注册表并更改值。
流量:
1.GetFile
2.UpdateAttribute //add schema.name attribute
3.ConvertRecord //define/use AvroSchemaRegistry and access strategy as schemaname property
..other processors
有关 defining/using AvroSchemaRegistry 的更多详细信息,请参阅 this link。
我有几个相同的并行流程(如屏幕截图所示)。我在每个相同的流程和记录 Reader 中都有 convertRecord,我使用 "Schema Text Field Property" 作为访问策略并指定了 "Schema text"。例如:
{
"type": "record",
"name": "AVLRecord0",
"fields" : [
{"name": "TimeOfDay", "type": "string", "logicalType":"timestamp-millis"},
{"name":"Field1", "type": "double"},
{"name":"Field2", "type": "double"},
{"name":"Field3", "type": "double"},
{"name": "Filename", "type": "string"}
]
}
假设我在各种并行流 ConvertRecord 中使用了上述模式,现在我想将一个字段名称从 Field 更新为 Field_Name 那么有没有我可以一次性完成所有转换记录模式文本的方法吗?
如果我想 change/update 模式文本中的字段之一,我是否必须手动 change/Update 每个处理器中的字段名称?或者有一种全局方式可以更改我拥有的所有并行流中的字段名称?
有什么方法可以一次性更新跨各种处理器的模式文本?
非常感谢任何帮助!谢谢
由于您正在使用 Schema Text Field Property
,因此您需要手动更改 所有 ConvertRecord 处理器。
试试这个方法:
在 ConvertRecord 处理器中使用 Schema Access Strategy as
Use Schema Name Property
然后设置 AvroSchemaRegistry 并通过添加新的 属性
来定义您的架构我已将 sch
添加为 schema.name 并定义了 avro 架构。
在 GetFile 处理器使用 UpdateAttribute
处理器后,将 schema.name
属性(例如:值为 sch)添加到流文件。
- 现在在 reader 控制器服务中使用模式访问策略作为已经设置的
Use Schema Name Property and Schema Registry as
AvroSchemaRegistry`。
通过这种方式,我们没有在所有 ConvertRecord
[=55= 上定义模式 ] 处理器,我们指的是 在 AvroSchemaRegistry
中定义的相同模式 以防万一,如果您想更改一个字段名称,很容易进入注册表并更改值。
流量:
1.GetFile
2.UpdateAttribute //add schema.name attribute
3.ConvertRecord //define/use AvroSchemaRegistry and access strategy as schemaname property
..other processors
有关 defining/using AvroSchemaRegistry 的更多详细信息,请参阅 this link。