PartitionRecord
Description
Splits, or partitions, record-oriented data based on the configured fields in the data. One or more properties must be added. The name of the property is the name of an attribute to add. The value of the property is a RecordPath to evaluate against each Record. Two records will go to the same outbound FlowFile only if they have the same value for each of the given RecordPaths. Because we know that all records in a given output FlowFile have the same value for the fields that are specified by the RecordPath, an attribute is added for each field. See Additional Details on the Usage page for more information and examples.
Tags
bin, group, organize, partition, record, recordpath, rpath, segment, split
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 |
---|---|---|
The name given to the dynamic property is the name of the attribute that will be used to denote the value of the associated RecordPath. | A RecordPath that points to a field in the Record. | Each dynamic property represents a RecordPath that will be evaluated against each record in an incoming FlowFile. When the value of the RecordPath is determined for a Record, an attribute is added to the outgoing FlowFile. The name of the attribute is the same as the name of this property. The value of the attribute is the same as the value of the field in the Record that the RecordPath points to. Note that no attribute will be added if the value returned for the RecordPath is null or is not a scalar value (i.e., the value is an Array, Map, or Record). Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables. |
Relationships
Name | Description |
---|---|
failure | If a FlowFile cannot be partitioned from the configured input format to the configured output format, the unchanged FlowFile will be routed to this relationship |
original | Once all records in an incoming FlowFile have been partitioned, the original FlowFile is routed to this relationship. |
success | FlowFiles that are successfully partitioned will be routed to this relationship |
Reads Attributes
This processor does not read attributes.
Writes Attributes
Name | Description |
---|---|
<dynamic property name> | For each dynamic property that is added, an attribute may be added to the FlowFile. See the description for Dynamic Properties for more information. |
fragment.count | The number of partitioned FlowFiles generated from the parent FlowFile |
fragment.identifier | All partitioned FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute |
fragment.index | A one-up number that indicates the ordering of the partitioned FlowFiles that were created from a single parent FlowFile |
mime.type | The MIME Type that the configured Record Writer indicates is appropriate |
record.count | The number of records in an outgoing FlowFile |
segment.original.filename | The filename of the parent FlowFile |
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
Separate records into separate FlowFiles so that all of the records in a FlowFile have the same value for a given field or set of fields.
Configuration
Choose a RecordReader that is appropriate based on the format of the incoming data.
Choose a RecordWriter that writes the data in the desired output format.
Add a single additional property. The name of the property should describe the type of data that is being used to partition the data. The property's value should be a RecordPath that specifies which output FlowFile the Record belongs to.
For example, if we want to separate records based on their transactionType
field, we could add a new property named transactionType
. The value of the property might be /transaction/type
. An input FlowFile will then be separated into as few FlowFiles as possible such that each output FlowFile has the same value for the transactionType
field.
Use Case 2
Separate records based on whether or not they adhere to a specific criteria
Configuration
Choose a RecordReader that is appropriate based on the format of the incoming data.
Choose a RecordWriter that writes the data in the desired output format.
Add a single additional property. The name of the property should describe the criteria. The property's value should be a RecordPath that returns true
if the Record meets the criteria or false
otherwise.
For example, if we want to separate records based on whether or not they have a transaction total of more than $1,000 we could add a new property named largeTransaction
with a value of /transaction/total > 1000
. This will create two FlowFiles. In the first, all records will have a total over 1000
. In the second, all records will have a transaction less than or equal to 1000. Each FlowFile will have an attribute named largeTransaction
with a value of true
or false
.
System Resource Considerations
This component does not specify system resource considerations.