RenameRecordField
Description
Renames one or more fields in each Record of a FlowFile. This Processor requires that at least one user-defined Property be added. The name of the Property should indicate a RecordPath that determines the field that should be updated. The value of the Property is the new name to assign to the Record Field that matches the RecordPath. The property value may use Expression Language to reference FlowFile attributes as well as the variables field.name
, field.value
, field.type
, and record.index
Tags
avro, csv, field, generic, json, log, logs, record, rename, schema, update
Properties
In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.
Display Name | API Name | Default Value | Allowable Values | Description |
---|---|---|---|---|
Record Reader * | Record Reader | Controller Service: RecordReaderFactory Implementations: AvroReader CEFReader CSVReader ExcelReader GrokReader JsonPathReader JsonTreeReader ReaderLookup ScriptedReader Syslog5424Reader SyslogReader WindowsEventLogReader XMLReader YamlTreeReader | Specifies the Controller Service to use for reading incoming data | |
Record Writer * | Record Writer | Controller Service: RecordSetWriterFactory Implementations: AvroRecordSetWriter CSVRecordSetWriter FreeFormTextRecordSetWriter JsonRecordSetWriter RecordSetWriterLookup ScriptedRecordSetWriter XMLRecordSetWriter | Specifies the Controller Service to use for writing out the records |
Dynamic Properties
Name | Value | Description |
---|---|---|
A RecordPath that identifies which field(s) to update | The new name to assign to the Record field | Allows users to specify a new name for each field that matches the RecordPath. Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables. |
Relationships
Name | Description |
---|---|
failure | If a FlowFile cannot be transformed from the configured input format to the configured output format, the unchanged FlowFile will be routed to this relationship |
success | FlowFiles that are successfully transformed will be routed to this relationship |
Reads Attributes
This processor does not read attributes.
Writes Attributes
Name | Description |
---|---|
record.index | This attribute provides the current row index and is only available inside the literal value expression. |
State Management
This component does not store state.
Restricted
This component is not restricted.
Input Requirement
This component requires an incoming relationship.
Example Use Cases
Use Case 1
Rename a field in each Record to a specific, known name.
Configuration
Configure the 'Record Reader' according to the input format.
Configure the 'Record Writer' according to the desired output format.
Add a property to the Processor such that the name of the property is a RecordPath to identifies the field to rename. The value of the property is the new name of the property.
For example, to rename the name
field to full_name
, add a property with a name of /name
and a value of full_name
.
Many properties can be added following this pattern in order to rename multiple fields.
Use Case 2
Rename a field in each Record to a name that is derived from a FlowFile attribute.
Configuration
Configure the 'Record Reader' according to the input format.
Configure the 'Record Writer' according to the desired output format.
Add a property to the Processor such that the name of the property is a RecordPath to identifies the field to rename. The value of the property is an Expression Language expression that can be used to determine the new name of the field.
For example, to rename the addr
field to whatever value is stored in the preferred_address_name
attribute, add a property with a name of /name
and a value of ${preferred_address_name}
.
Many properties can be added following this pattern in order to rename multiple fields.
Use Case 3
Rename a field in each Record to a new name that is derived from the current field name.
This might be used, for example, to add a prefix or a suffix to some fields, or to transform the name of the field by making it uppercase.
Configuration
Configure the 'Record Reader' according to the input format.
Configure the 'Record Writer' according to the desired output format.
Add a property to the Processor such that the name of the property is a RecordPath to identifies the field to rename. The value of the property is an Expression Language expression that references the field.name
property.
For example, to rename all fields with a prefix of pre_
, we add a property named /*
and a value of pre_$\{field.name}
. If we would like this to happen recursively, to nested fields as well, we use a property name of //*
with the value of pre_$\{field.name}
.
To make all field names uppercase, we can add a property named //*
with a value of ${field.name:toUpper()}
.
Many properties can be added following this pattern in order to rename multiple fields.
System Resource Considerations
This component does not specify system resource considerations.