.. meta:: :description: This document provides usage information for the Apache Kafka SMT org.apache.kafka.connect.transforms.ReplaceField. .. _replacefield: ============ ReplaceField ============ The following provides usage information for the |ak-tm| SMT ``org.apache.kafka.connect.transforms.ReplaceField``. Description ----------- 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``). Examples -------- These examples show how to configure and use ``ReplaceField``. ------------ Drop a Field ------------ This configuration snippet shows how to use ``ReplaceField`` to exclude a field and remove it. .. code-block:: json "transforms": "ReplaceField", "transforms.ReplaceField.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", "transforms.ReplaceField.exclude": "c2" This removes ``c2``, transforming the original message as seen here: ``{"c1":22,"c2":"foo"}`` to this result: ``{"c1":22}`` -------------- Rename a Field -------------- This configuration snippet shows how to use ``ReplaceField`` with the ``renames`` property. .. code-block:: json "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``. Before: ``{"foo":22,"bar":"baz"}`` After: ``{"c1":22,"c2":"baz"}`` .. tip:: For additional examples, see `Replace Field `__ for managed connectors. Properties ---------- .. list-table:: :header-rows: 1 :widths: 15 30 10 10 10 10 * - Name - Description - Type - Default - Valid Values - Importance * - ``exclude`` - Fields to exclude from the resulting Struct or Map. This takes precedence over the include list. - list - "" - Comma-separated list of fields to exclude. - medium * - ``renames`` - Field rename mappings. - list - "" - Comma-separated list of colon-delimited renaming pairs, e.g. ``foo:bar,abc:xyz`` - medium * - ``include`` - Fields to include. If specified, only the named fields will be included in the resulting Struct or Map. - list - "" - Comma-separated list of fields to include. - medium .. include:: includes/predicate.rst