Field Renamer
Use the Field Renamer to rename fields in a record. You can specify individual fields to rename or use regular expressions to rename sets of fields.
You can configure the behavior when a source field does not exist, when a target field with a matching name already exists, and when a source field matches multiple source field expressions.
Fields that are not renamed or overwritten pass to the next stage.
Renaming Sets of Fields
You can use regular expressions, or regex, along with the StreamSets expression language to rename sets of fields. You can use regex to define the set of source fields to rename and to define the target field names. You can also use the StreamSets expression language to define target field names.
- Remove a prefix or suffix
-
Say you want to remove an OPS prefix from a set of fields. You can do this by using the following expression to define the source fields to change:
/'OPS(.*)'
Then use the following expression to remove the OPS prefix:/$1
- Remove special characters
- To remove special characters from field names, you can use the following
expression for the source field
names:
/'([A-Z a-z]*)[^a-z A-Z 0-9]([A-Z a-z 0-9]*)'
- Change capitalization
- To change field names to all uppercase, use the following expression for the
source field names:
/(.*)
Then use the following expression for the target field names:/${str:toUpper("$1")}
tag|attr
, enter the field name as follows:
/'tag|attr'