CONFLUENT PLATFORM
The following provides usage information for the Apache Kafka® SMT org.apache.kafka.connect.transforms.ReplaceField.
org.apache.kafka.connect.transforms.ReplaceField
Filter or rename fields within a Struct or Map.
Use the concrete transformation type designed for the record key (org.apache.kafka.connect.transforms.ReplaceField$Key) or value (org.apache.kafka.connect.transforms.ReplaceField$Value).
org.apache.kafka.connect.transforms.ReplaceField$Key
org.apache.kafka.connect.transforms.ReplaceField$Value
These examples show how to configure and use ReplaceField.
ReplaceField
This configuration snippet shows how to use ReplaceField to blacklist a field and remove it.
"transforms": "ReplaceField", "transforms.ReplaceField.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", "transforms.ReplaceField.blacklist": "c2"
This removes c2, transforming the original message as seen here:
c2
{"c1":22,"c2":"foo"}
to this result:
{"c1":22}
This configuration snippet shows how to use ReplaceField with the renames property.
renames
"transforms": "RenameField", "transforms.RenameField.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", "transforms.RenameField.renames": "foo:c1,bar:c2"
This replaces the foo and bar field names with c1 and c2.
foo
bar
c1
Before: {"foo":22,"bar":"baz"}
{"foo":22,"bar":"baz"}
After: {"c1":22,"c2":"baz"}
{"c1":22,"c2":"baz"}
blacklist
foo:bar,abc:xyz
whitelist
Transformations can be configured with predicates so that the transformation is applied only to records which satisfy a condition. You can use predicates in a transformation chain and, when combined with the Filter (Apache Kafka), predicates can conditionally filter out specific records. For details and examples, see Predicates.