Skip to main content

UpdateRecord

Description

Updates the contents of a FlowFile that contains Record-oriented data (i.e., data that can be read via a RecordReader and written by a RecordWriter). 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 either a replacement value (optionally making use of the Expression Language) or is itself a RecordPath that extracts a value from the Record. Whether the Property value is determined to be a RecordPath or a literal value depends on the configuration of the <Replacement Value Strategy> Property.

Tags

avro, csv, freeform, generic, json, log, logs, record, schema, text, 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 NameAPI NameDefault ValueAllowable ValuesDescription
Record Reader *Record ReaderController 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 WriterController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
Specifies the Controller Service to use for writing out the records
Replacement Value Strategy *Replacement Value StrategyLiteral Value
  • Literal Value
  • Record Path Value
Specifies how to interpret the configured replacement values

Dynamic Properties

NameValueDescription
A RecordPath.The value to use to replace fields in the record that match the RecordPathAllows users to specify values to use to replace fields in the record that match the RecordPath.

Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables.

Relationships

NameDescription
failureIf a FlowFile cannot be transformed from the configured input format to the configured output format, the unchanged FlowFile will be routed to this relationship
successFlowFiles that are successfully transformed will be routed to this relationship

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
record.error.messageThis attribute provides on failure the error message encountered by the Reader or Writer.
record.indexThis 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

Combine multiple fields into a single field.

Configuration

"Replacement Value Strategy" = "Record Path Value"

A single additional property is added to the Processor. The name of the property is a RecordPath identifying the field to place the result in.
The value of the property uses the CONCAT Record Path function to concatenate multiple values together, potentially using other string literal values.
For example, to combine the title, firstName and lastName fields into a single field named fullName, we add a property with the name /fullName and a value of CONCAT(/title, ' ', /firstName, ' ', /lastName)

Use Case 2

Change the value of a record field to an explicit value.

Configuration

"Replacement Value Strategy" = "Literal Value"

A single additional property is added to the Processor. The name of the property is a RecordPath identifying the field to place the result in.
The value of the property is the explicit value to set the field to. For example, we can set any field with a name of txId, regardless of its level in the data's hierarchy, to 1111-1111 by adding a property with a name of //txId and a value of 1111-1111

Use Case 3

Copy the value of one record field to another record field.

Configuration

"Replacement Value Strategy" = "Record Path Value"

A single additional property is added to the Processor. The name of the property is a RecordPath identifying the field to update.
The value of the property is a RecordPath identifying the field to copy the value from.
For example, we can copy the value of /identifiers/all/imei to the identifier field at the root level, by adding a property named /identifier with a value of /identifiers/all/imei.

Use Case 4

Enrich data by injecting the value of an attribute into each Record.

Configuration

"Replacement Value Strategy" = "Literal Value"

A single additional property is added to the Processor. The name of the property is a RecordPath identifying the field to place the result in.
The value of the property is an Expression Language expression that references the attribute of interest. We can, for example, insert a new field name filename into each record by adding a property named /filename with a value of ${filename}

Use Case 5

Change the format of a record field's value.

Use the RenameRecordField Processor in order to change a field's name.

Configuration

"Replacement Value Strategy" = "Literal Value"

A single additional property is added to the Processor. The name of the property is a RecordPath identifying the field to update.
The value is an Expression Language expression that references the field.value variable. For example, to change the date/time format of a field named txDate from year-month-day format to month/day/year format, we add a property named /txDate with a value of ${field.value:toDate('yyyy-MM-dd'):format('MM/dd/yyyy')}. We could also change the timezone of a timestamp field (and insert the timezone for clarity) by using a value of ${field.value:toDate('yyyy-MM-dd HH:mm:ss', 'UTC-0400'):format('yyyy-MM-dd HH:mm:ss Z', 'UTC')}.

System Resource Considerations

This component does not specify system resource considerations.

See Also

ConvertRecord