I have a NiFi flow with a number of processes. At a certain stage in the flow, a file has been read and some attributes have been added to the flowfile. The existing processes are legacy and so I cannot change the original name of the attribute in the legacy process. And the process may be used elsewhere.
So downstream, I now want to rename attribute 'A' to 'B' using a process configured at the NiFi GUI.
How do I rename an Attribute?
I can use UpdateAttribute and create a new property b and set its value to ${A}. But how do I delete property/attribute A?
UpdateAttribute includes a "Delete Attributes Expression" property that can delete an attribute.
You can use 1 UpdateAttribute processor to create a new Attribute called B with the value of A, then add A to the "Delete Attributes Expression". It will do the Update and then the Delete - so it effectively renames the attribute.
"The third way is the "Delete Attributes Expression"; this allows you to provide a regular expression and any attributes with a matching name will be deleted.
Please note that "Delete Attributes Expression" supersedes any updates that occur. If an existing attribute matches the "Delete Attributes Expression", it will be removed whether it was updated or not. That said, the "Delete Attributes Expression" only applies to attributes that exist in the input FlowFile, if it is added by this processor, the "Delete Attributes Expression" will not detect it."