Class RenameRecordField
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.AbstractRecordProcessor
org.apache.nifi.processors.standard.RenameRecordField
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@InputRequirement(INPUT_REQUIRED)
@Tags({"update","record","rename","field","generic","schema","json","csv","avro","log","logs"})
@CapabilityDescription("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`")
@WritesAttributes(@WritesAttribute(attribute="record.index",description="This attribute provides the current row index and is only available inside the literal value expression."))
@DynamicProperty(name="A RecordPath that identifies which field(s) to update",
value="The new name to assign to the Record field",
description="Allows users to specify a new name for each field that matches the RecordPath.",
expressionLanguageScope=FLOWFILE_ATTRIBUTES)
@SeeAlso({UpdateRecord.class,RemoveRecordField.class})
@UseCase(description="Rename a field in each Record to a specific, known name.",keywords={"rename","field","static","specific","name"},configuration="Configure the \'Record Reader\' according to the input format.\nConfigure the \'Record Writer\' according to the desired output format.\n\nAdd 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.\n\nFor example, to rename the `name` field to `full_name`, add a property with a name of `/name` and a value of `full_name`.\n\nMany properties can be added following this pattern in order to rename multiple fields.\n") @UseCase(description="Rename a field in each Record to a name that is derived from a FlowFile attribute.",keywords={"rename","field","expression language","EL","flowfile","attribute"},configuration="Configure the \'Record Reader\' according to the input format.\nConfigure the \'Record Writer\' according to the desired output format.\n\nAdd 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.\n\nFor 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}`.\n\nMany properties can be added following this pattern in order to rename multiple fields.\n") @UseCase(description="Rename a field in each Record to a new name that is derived from the current field name.",notes="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.",keywords={"rename","field","expression language","EL","field.name"},configuration="Configure the \'Record Reader\' according to the input format.\nConfigure the \'Record Writer\' according to the desired output format.\n\nAdd 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.\n\nFor 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}`.\n\nTo make all field names uppercase, we can add a property named `//*` with a value of `${field.name:toUpper()}`.\n\nMany properties can be added following this pattern in order to rename multiple fields.\n")
public class RenameRecordField
extends AbstractRecordProcessor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate RecordPathCacheFields inherited from class org.apache.nifi.processors.standard.AbstractRecordProcessor
INCLUDE_ZERO_RECORD_FLOWFILES, RECORD_READER, RECORD_WRITER, REL_FAILURE, REL_SUCCESS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateRecordPaths(org.apache.nifi.processor.ProcessContext context) protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) protected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) protected Recordprocess(Record record, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context, long count) Methods inherited from class org.apache.nifi.processors.standard.AbstractRecordProcessor
getRelationships, getSupportedPropertyDescriptors, migrateProperties, onTriggerMethods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
FIELD_NAME
- See Also:
-
FIELD_VALUE
- See Also:
-
FIELD_TYPE
- See Also:
-
RECORD_INDEX
- See Also:
-
recordPathCache
-
recordPaths
-
-
Constructor Details
-
RenameRecordField
public RenameRecordField()
-
-
Method Details
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
createRecordPaths
@OnScheduled public void createRecordPaths(org.apache.nifi.processor.ProcessContext context) -
process
protected Record process(Record record, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context, long count) - Specified by:
processin classAbstractRecordProcessor
-