Debezium Transformations

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

A Debezium source connector turns every committed row change in the legacy database into a change event. Those events are faithful to the legacy schema: one topic per table, upper-case Oracle column names, a key made of the legacy primary key, and an envelope with before, after, source and op. That is exactly what you want to keep in Kafka as the record of what happened. It is not always what each consumer wants to read. Some events should go to a different topic, some should not leave the connector at all, some need a different partition so that a consumer sees them in the right order, and some need an extra header or field.

Kafka Connect solves this with single message transformations (SMTs): small, stateless functions that run inside the Connect worker on one record at a time, either after a source connector produces the record or before a sink connector consumes it. The general mechanism (the transforms list, the order of execution, and the fact that SMTs are not a stream processor) is explained on Kafka Connect. This page covers the SMTs that Debezium itself ships, from the point of view of a migration: what each one is for, when it helps you move data from the legacy Bookshop Oracle schema to the new PostgreSQL model, and what goes wrong when it is misused.

Three of Debezium’s transformations are important enough to have their own pages: Event Flattening (ExtractNewRecordState and its MongoDB variants), Outbox Event Router and, for type changes that must happen inside the connector rather than after it, Custom Converters & Post Processors.

Checked on 2026-11-09 against Debezium 3.7.1.Final, Apache Kafka 4.3 (the Kafka version Debezium 3.7.1.Final is built against) and the Debezium 3.7.1.Final BOM for the scripting engine versions. The configuration on this page is derived from the official documentation and was not run against a live connector.

What an SMT can and cannot do in a migration

An SMT sees one record: its topic, key, value, their schemas, its headers and its timestamp. It can change any of them, return a different record, or return null to drop the record. It cannot look at other records, call the database, or keep state between records (apart from caches). That makes SMTs a good fit for:

  • Routing: choosing the destination topic or partition of an event.

  • Filtering: dropping events that the new system must not receive.

  • Reshaping: removing the envelope, adding metadata fields or headers, converting a type or a time zone.

It makes them a poor fit for anything that needs joins or aggregation, such as turning the legacy ORDERS and ORDER_LINE events into one purchase_order aggregate. That work belongs in the anti-corruption layer (LegacyOrderProjector, see Listening to Events in Applications) or in Kafka Streams.

Where you attach an SMT matters:

Attached to What is stored in Kafka When to use it

The Debezium source connector (bookshop-oracle-source)

The transformed record. The original change event is lost.

Routing and partitioning that every consumer needs, filtering that must happen before data leaves the legacy database (for example personal data that the new system must never see).

A sink connector (bookshop-pg-mirror-sink)

The original change event. Only this sink sees the transformed version.

Reshaping for one consumer. Other consumers, replays and reconciliation still get the full event.

Debezium Server or the Debezium Engine

There is no Kafka in between, so the transformed record is what the sink receives.

The same transforms syntax, with the debezium.transforms prefix in Debezium Server.

The safe default for a migration is: keep the source connector’s output complete and close to the legacy schema, and reshape on the way out. Kafka then holds an exact, replayable record of every legacy change, which is what Verification & Reconciliation relies on.

The order of the aliases in transforms is the order in which they run. Kafka Connect applies each transformation to the output of the previous one, so a filter that reads value.op must run before a transformation that removes the envelope.

flowchart LR DB[(Oracle BOOKSHOP)] --> SRC[bookshop-oracle-source] SRC --> T1[SMT 1: filter] T1 --> T2[SMT 2: partition routing] T2 --> CONV[Converter: JSON or Avro] CONV --> K[(Kafka topics legacy.BOOKSHOP.*)] K --> S1[SMT on the sink] S1 --> SINK[bookshop-pg-mirror-sink] SINK --> PG[(PostgreSQL bookshop)]

The SMTs that Debezium provides

The official overview lists the following transformations. The class names are the values you put in transforms.<alias>.type.

Transformation Class Typical migration use

Topic routing

io.debezium.transforms.ToLogicalTopicRouter

Merge several physical tables (archive tables, shards, partitions) into one topic.

Content-based routing

io.debezium.transforms.ContentBasedRouter

Send some events of a table to a different topic, based on their content.

Message filtering

io.debezium.transforms.Filter

Drop events that the new system must not receive.

New record state extraction

io.debezium.transforms.ExtractNewRecordState

Flatten the envelope for non-Debezium sinks. See Event Flattening.

MongoDB new document state extraction

io.debezium.connector.mongodb.transforms.ExtractNewDocumentState

The MongoDB counterpart. See Event Flattening.

MongoDB relational mapping

io.debezium.connector.mongodb.transforms.MongoToRelationalMapper

Project MongoDB documents to fixed relational columns. See Event Flattening.

Event changes

io.debezium.transforms.ExtractChangedRecordState

Add headers that list the changed and unchanged fields of an update.

Outbox event router

io.debezium.transforms.outbox.EventRouter

Publish domain events from an outbox table. See Outbox Event Router.

MongoDB outbox event router

io.debezium.connector.mongodb.transforms.outbox.MongoEventRouter

The MongoDB counterpart.

Schema change event filtering

io.debezium.transforms.SchemaChangeEventFilter

Hide DROP or TRUNCATE schema change events from downstream consumers.

Partition routing

io.debezium.transforms.partitions.PartitionRouting

Choose the partition from payload fields, for example all lines of one order on one partition.

HeaderToValue

io.debezium.transforms.HeaderToValue

Move or copy headers into the record value.

Timezone converter

io.debezium.transforms.TimezoneConverter

Convert timestamp fields to a target time zone.

Geometry format transformer

io.debezium.transforms.GeometryFormatTransformer

Convert geometries between WKB and EWKB.

Swap geometry coordinates

io.debezium.transforms.SwapGeometryCoordinates

Swap the axis order of geometries for selected SRIDs.

TimescaleDB integration

io.debezium.connector.postgresql.transforms.timescaledb.TimescaleDb

Reassemble hypertable chunks into one logical topic.

Decode logical decoding message content

io.debezium.connector.postgresql.transforms.DecodeLogicalDecodingMessageContent

Turn a PostgreSQL logical decoding message into a structured, insert-like event.

Vector to JSON

io.debezium.transforms.VectorToJsonConverter

Write vector columns to a target database without a vector type.

Neo4j CUD converter

io.debezium.transforms.Neo4jCudConverter

Feed a relational-to-graph migration through the Neo4j Kafka sink.

Enforce record size

io.debezium.transforms.EnforceRecordSize

Truncate large string and bytes columns when a record exceeds a size limit.

Vitess: use local VGTID, remove field, replace field value, filter transaction topic records

io.debezium.connector.vitess.transforms.UseLocalVgtid, ...RemoveField, ...ReplaceFieldValue, ...FilterTransactionTopicRecords

Only for the Vitess connector (incubating).

Most of these are in every Debezium connector archive and in the quay.io/debezium/connect:3.7.1.Final image. The two scripting-based transformations, content-based routing and message filtering, are not. They are an explicit opt-in, described below.

Applying transformations selectively with predicates

A Debezium connector emits more than data change events. Depending on its configuration it also emits heartbeat messages, tombstones after deletes, schema change events and transaction metadata. Those records do not have an op field or an after struct, so an SMT written for change events can fail on them. The fix is a predicate: a condition that Kafka Connect checks before it runs a transformation. When the predicate is false, the record passes through unchanged.

Kafka Connect (2.6 or later) provides three predicate types:

TopicNameMatches

True when the topic name matches the regular expression in pattern. Use it to restrict an SMT to the topics of some tables.

HasHeaderKey

True when the record has a header with the name given in name.

RecordIsTombstone

True for records with a null value. It has no configuration.

A predicate is declared once under predicates and attached to one or more transformations with transforms.<alias>.predicate. transforms.<alias>.negate=true inverts the match, so the transformation runs on the records that do not match.

Applying an SMT only to the BOOKSHOP.BOOK topic
transforms=changes
transforms.changes.type=io.debezium.transforms.ExtractChangedRecordState
transforms.changes.header.changed.name=Changed
transforms.changes.predicate=isBookTopic

predicates=isBookTopic
predicates.isBookTopic.type=org.apache.kafka.connect.transforms.predicates.TopicNameMatches
predicates.isBookTopic.pattern=legacy\\.BOOKSHOP\\.BOOK

In a .properties file a backslash must be doubled, so legacy\\.BOOKSHOP\\.BOOK is the regular expression legacy\.BOOKSHOP\.BOOK. In connector JSON the same escaping applies ("legacy\\.BOOKSHOP\\.BOOK"). An unescaped dot also matches, which is harmless here but becomes a bug when a table name is a prefix of another one (BOOK and BOOK_ARCHIVE): TopicNameMatches uses a full match, so add .* only when you want a prefix match.

Each transformation has one predicate. To exclude tombstones from a transformation that already has a topic predicate, either rely on the transformation’s own null handling (the scripting SMTs have null.handling.mode) or split the work into two aliases.

Some Debezium SMTs also have their own topic filter: topic.regex on the content-based router and the filter, and route.topic.regex on the outbox event router. A predicate is the more general mechanism and works the same way on every SMT, including Kafka’s own.

The official page also discusses tombstones: Debezium emits one after every delete (tombstones.on.delete=true by default) so that Kafka log compaction can remove the deleted key. If a sink cannot process tombstones, keep them in the topic and drop them at the sink with Kafka’s Filter transformation combined with RecordIsTombstone, instead of switching them off at the source.

Dropping tombstones at a sink that cannot handle them
transforms=dropTombstones
transforms.dropTombstones.type=org.apache.kafka.connect.transforms.Filter
transforms.dropTombstones.predicate=isTombstone
predicates=isTombstone
predicates.isTombstone.type=org.apache.kafka.connect.transforms.predicates.RecordIsTombstone

The Debezium JDBC sink uses tombstones and delete events (with delete.enabled=true), so do not add this to bookshop-pg-mirror-sink.

Topic routing: merging tables into one topic

By default each captured table gets its own topic, <topic.prefix>.<schema>.<table>. When several physical tables hold the same kind of data, the new system usually wants one stream. Typical legacy cases are:

  • Yearly archive tables with the same columns (for example ORDERS_ARCH_2024 and ORDERS_ARCH_2025; the running Bookshop example does not have them, but many legacy schemas do).

  • Sharded schemas, where shard1.customers and shard2.customers form one logical table.

  • PostgreSQL partitioned tables, where each partition otherwise gets its own topic.

The topic routing SMT, io.debezium.transforms.ToLogicalTopicRouter, rewrites the topic name with a regular expression. Older Debezium releases and many blog posts call it ByLogicalTableRouter; the Debezium 3.7 documentation uses only ToLogicalTopicRouter.

Routing archive tables into the ORDERS topic
{
  "transforms": "reroute",
  "transforms.reroute.type": "io.debezium.transforms.ToLogicalTopicRouter",
  "transforms.reroute.topic.regex": "legacy\\.BOOKSHOP\\.ORDERS(_ARCH_[0-9]{4})?",
  "transforms.reroute.topic.replacement": "legacy.BOOKSHOP.ORDERS_ALL",
  "transforms.reroute.key.field.name": "source_table",
  "transforms.reroute.key.field.regex": "legacy\\.BOOKSHOP\\.(.*)",
  "transforms.reroute.key.field.replacement": "$1"
}

The fragment goes into the config object of bookshop-oracle-source, next to the connector’s own properties. The tables must have the same schema; the SMT does not check that.

Keys stay unique, unless you say otherwise

Each archive table has its own primary key sequence, so order 4711 can exist in ORDERS and in ORDERS_ARCH_2024. If both events land in one topic with the key {"ORDER_ID": "4711"}, a compacted topic keeps only one of them, and a sink that upserts by key overwrites one order with the other. To prevent that, ToLogicalTopicRouter adds a field to the key whose value identifies the source table. The default field name is __dbz__sourceIdentifier and its default value is the original topic name. In the example above the field is renamed to source_table and its value is the captured group, so the key becomes {"ORDER_ID": "4711", "source_table": "ORDERS_ARCH_2024"}.

When the keys are unique across the merged tables (PostgreSQL partitions, or legacy tables that share one Oracle sequence), set key.enforce.uniqueness=false so that the key keeps the legacy primary key only.

Option Default Meaning

topic.regex

none

Regular expression that selects the topics to re-route.

topic.replacement

none

Destination topic. Can refer to groups of topic.regex ($1, $2).

key.enforce.uniqueness

true

Add a field to the key so that keys from different tables cannot collide.

key.field.name

__dbz__sourceIdentifier

Name of the added key field.

key.field.regex

none

Regular expression applied to the original topic name to compute the key field value.

key.field.replacement

none

Value of the key field, in terms of the groups captured by key.field.regex.

schema.name.adjustment.mode

none

avro replaces characters that are invalid in Avro type names.

logical.destination.cache.size

16

Size of the LRU cache of derived schemas and topic names.

Two things go wrong in practice. First, the merged topic now has one key schema with an extra field, so any consumer that reads the key (the JDBC sink with primary.key.mode=record_key, for instance) must expect it. Second, the SMT also changes the key schema name, so with Avro and a schema registry you get a new subject; set schema.name.adjustment.mode=avro when the topic name contains characters Avro does not allow.

Content-based routing and filtering

Topic routing looks at topic names. Two Debezium SMTs look at the content of each event and evaluate an expression that you write in configuration:

  • io.debezium.transforms.ContentBasedRouter evaluates topic.expression. A non-null string result is the new topic name; null keeps the default topic.

  • io.debezium.transforms.Filter evaluates condition. true keeps the record; false drops it.

Both bind the same variables into the expression: key, value, keySchema, valueSchema, topic and header (a map of header name to a RecordHeader with value and schema).

What you must install: the scripting artifact and a language

For security reasons these two SMTs are not included in the connector archives. Anyone who can create a connector on a Connect cluster that has them installed can run arbitrary script code inside the worker, so secure the Connect REST API before you add them (see Security & Data Protection). The official pages list these pieces:

  1. The SMT itself: debezium-scripting-3.7.1.Final.tar.gz from Maven Central (https://repo1.maven.org/maven2/io/debezium/debezium-scripting/3.7.1.Final/debezium-scripting-3.7.1.Final.tar.gz). The archive contains a single JAR, debezium-scripting-3.7.1.Final.jar. Extract it into the plug-in directory of each Debezium connector that uses it.

  2. A JSR 223 script engine for the language. Debezium does not ship one.

    • Groovy needs groovy, groovy-jsr223 and, if you parse JSON in expressions, groovy-json. The Maven coordinates are org.apache.groovy:groovy, org.apache.groovy:groovy-jsr223 and org.apache.groovy:groovy-json. The Debezium 3.7.1.Final BOM pins them at 4.0.17.

    • GraalVM JavaScript needs graalvm.js and graalvm.js.scriptengine. The Debezium 3.7.1.Final BOM uses org.graalvm.js:js-language and org.graalvm.js:js-scriptengine at 25.0.1.

    • Go (incubating) needs no script engine: you compile the expression to a WebAssembly file with TinyGo, using the community github.com/debezium/debezium-smt-go-pdk, and Debezium runs it with the Chicory runtime.

  3. Restart the Connect worker so that it picks up the JARs.

The quay.io/debezium/connect:3.7.1.Final image already contains the scripting JAR in an external library folder and links it into every connector directory when the container starts with ENABLE_DEBEZIUM_SCRIPTING=true. It does not contain a Groovy or JavaScript engine, so you still add the language JARs, for example by extending the image.

Extending the Debezium Connect image with scripting and Groovy
FROM quay.io/debezium/connect:3.7.1.Final

ENV ENABLE_DEBEZIUM_SCRIPTING=true \
    GROOVY_VERSION=4.0.17 \
    MAVEN_CENTRAL=https://repo1.maven.org/maven2

# Copy the Groovy JSR 223 engine into each connector directory that uses the scripting SMTs
RUN for connector in debezium-connector-oracle debezium-connector-postgres; do \
      for artifact in groovy groovy-jsr223 groovy-json; do \
        curl -fsSL -o "$KAFKA_CONNECT_PLUGINS_DIR/$connector/$artifact-$GROOVY_VERSION.jar" \
          "$MAVEN_CENTRAL/org/apache/groovy/$artifact/$GROOVY_VERSION/$artifact-$GROOVY_VERSION.jar"; \
      done; \
    done

ENABLE_DEBEZIUM_SCRIPTING and the external library folder are described in the README of the debezium/container-images repository. The image runs as a non-root user; if your base image or a later Debezium image changes KAFKA_CONNECT_PLUGINS_DIR or the file permissions, adjust the RUN step. The Oracle connector directory also needs the Oracle JDBC driver, which Installing Debezium covers.

Filtering: only the pilot cohort of customers

The legacy migration path moves customers to the new system in cohorts behind a feature flag (see feature flags and cohort-based cut-over). Suppose the first cohort is every customer whose legacy id ends in 0. A filter on the source connector keeps the other customers' changes out of Kafka entirely.

Keeping only the pilot cohort’s CUSTOMER changes (Groovy)
{
  "transforms": "pilotCohort",
  "transforms.pilotCohort.type": "io.debezium.transforms.Filter",
  "transforms.pilotCohort.language": "jsr223.groovy",
  "transforms.pilotCohort.condition": "((value.op == 'd' ? value.before.CUST_ID : value.after.CUST_ID) as Long) % 10 == 0",
  "transforms.pilotCohort.null.handling.mode": "keep",
  "transforms.pilotCohort.predicate": "isCustomerTopic",
  "predicates": "isCustomerTopic",
  "predicates.isCustomerTopic.type": "org.apache.kafka.connect.transforms.predicates.TopicNameMatches",
  "predicates.isCustomerTopic.pattern": "legacy\\.BOOKSHOP\\.CUSTOMER"
}

How the pieces fit:

  • The predicate restricts the filter to the CUSTOMER topic, so the other tables, heartbeats and schema change events are not evaluated.

  • CUST_ID is a NUMBER(10). The Bookshop source uses decimal.handling.mode=string, so the Oracle connector emits it as a string ("70"), and the Groovy expression converts it with as Long before % 10; a bare % 10 on the string would fail. With the precise default it would be an INT64, and as Long is then a no-op (see Data Types & Precision).

  • A delete event has after == null, which is why the expression reads before for op == 'd'.

  • null.handling.mode=keep passes tombstones through without evaluating the expression. The other values are drop and evaluate.

Filtering at the source is permanent: a dropped event is not in Kafka and cannot be replayed. When the next cohort moves, changing the condition does not bring back the earlier changes for the new cohort’s customers. You need an incremental snapshot of BOOKSHOP.CUSTOMER for them (see Incremental & Blocking Snapshots). For that reason, many teams filter in the consumer or at the sink, and keep the source complete.

The same condition in the other languages:

language condition

jsr223.groovy

((value.op == 'd' ? value.before.CUST_ID : value.after.CUST_ID) as Long) % 10 == 0

jsr223.graal.js

Number(value.op == 'd' ? value.before.CUST_ID : value.after.CUST_ID) % 10 == 0

JavaScript with another JSR 223 engine

Use the Struct#get() method, as the official page shows: Number(value.get('op') == 'd' ? value.get('before').get('CUST_ID') : value.get('after').get('CUST_ID')) % 10 == 0.

wasm.chicory or wasm.chicory-interpreter

Set condition to the location of the compiled .wasm file, for example file://pilot-cohort.wasm (on the content-based router it goes in topic.expression). The official Go example sets expression, but in 3.7.1 the transformation reads the script only from condition (filter) or topic.expression (router), so a filter configured that way has no condition. This was checked in the 3.7.1 source, not run.

Content-based routing: cancelled orders to their own topic

The new order service owns cancellation earlier than the rest of the order life cycle. It wants legacy cancellations on their own topic so that it does not have to read every order change. The router sends updates of ORDERS whose new status is 'CN' to legacy.BOOKSHOP.ORDERS.cancelled, and leaves every other event on the default topic.

Routing cancelled orders to a separate topic (Groovy)
{
  "transforms": "routeCancelled",
  "transforms.routeCancelled.type": "io.debezium.transforms.ContentBasedRouter",
  "transforms.routeCancelled.language": "jsr223.groovy",
  "transforms.routeCancelled.topic.regex": "legacy\\.BOOKSHOP\\.ORDERS",
  "transforms.routeCancelled.topic.expression": "value.op == 'u' && value.after.STATUS_CD == 'CN' ? 'legacy.BOOKSHOP.ORDERS.cancelled' : null",
  "transforms.routeCancelled.null.handling.mode": "keep"
}

Here topic.regex plays the role of the predicate: only records for topics that match are evaluated. Watch out for two consequences of splitting a table across topics:

  • Kafka orders records only within a partition of one topic. A consumer that reads both topics can see the cancellation of order 4711 before an earlier update of the same order that stayed on the default topic. If the order of events matters, route by content in the consumer, not in Kafka.

  • STATUS_CD is VARCHAR2(2), so the comparison is a plain string comparison. A CHAR column would arrive blank-padded and need .trim().

MongoDB events in scripts

The MongoDB connector emits after (and patch in older event formats) as a JSON string, not a struct, so value.after.rating does not work for the legacy-mongo.bookshop.reviews events. Either run the MongoDB ExtractNewDocumentState SMT first (see Event Flattening) or parse the string in the expression, which needs groovy-json on the class path:

Filtering MongoDB review events by parsing the after document
transforms=positiveReviews
transforms.positiveReviews.type=io.debezium.transforms.Filter
transforms.positiveReviews.language=jsr223.groovy
transforms.positiveReviews.condition=value.after == null || (new groovy.json.JsonSlurper()).parseText(value.after).rating >= 1

Partition routing: keep the lines of one order together

The key of a legacy ORDER_LINE event is its primary key, (ORDER_ID, LINE_NO). Kafka’s default partitioner hashes the whole key, so the five lines of one order can land on five different partitions. LegacyOrderProjector runs with several consumer threads in the group bookshop-legacy-sync, so it can process line 3 of an order before line 1, or before the order header has been projected.

The partition routing SMT, io.debezium.transforms.partitions.PartitionRouting, computes the partition from fields of the payload instead of the key. Routing ORDER_LINE by ORDER_ID puts every line of an order on the same partition, in commit order.

Partitioning ORDER_LINE events by ORDER_ID
{
  "topic.creation.default.partitions": "6",
  "topic.creation.default.replication.factor": "3",
  "transforms": "byOrder",
  "transforms.byOrder.type": "io.debezium.transforms.partitions.PartitionRouting",
  "transforms.byOrder.partition.payload.fields": "change.ORDER_ID",
  "transforms.byOrder.partition.topic.num": "6",
  "transforms.byOrder.partition.hash.function": "murmur",
  "transforms.byOrder.predicate": "isOrderLineTopic",
  "predicates": "isOrderLineTopic",
  "predicates.isOrderLineTopic.type": "org.apache.kafka.connect.transforms.predicates.TopicNameMatches",
  "predicates.isOrderLineTopic.pattern": "legacy\\.BOOKSHOP\\.ORDER_LINE"
}

The options:

partition.payload.fields

Comma-separated payload fields, in dot notation. after.X and before.X select a specific image; the special prefix change uses after for creates and updates and before for deletes. Fields that are missing are skipped; if none exists, the record goes to its default partition.

partition.topic.num

The number of partitions of the topic. It must equal the real partition count, here the one set by topic.creation.default.partitions (see the topic auto-creation section of Features & Delivery Guarantees). If the topic later gets more partitions, update both values together, and remember that the mapping of orders to partitions changes.

partition.hash.function

java (default, Object::hashCode) or murmur (MurmurHash3).

The ComputePartition SMT of older releases is discontinued; the official page shows how to migrate its configuration to PartitionRouting.

HeaderToValue: moving headers into the record

Some information travels in headers: the Changed header of the event changes SMT, the __op header that event flattening can add, or headers set by your own SMTs. Many sinks ignore headers. io.debezium.transforms.HeaderToValue copies or moves headers into fields of the value, with dot notation for nesting.

Copying the Changed header into the source block of the value
transforms=changes,headerToValue
transforms.changes.type=io.debezium.transforms.ExtractChangedRecordState
transforms.changes.header.changed.name=Changed
transforms.headerToValue.type=io.debezium.transforms.HeaderToValue
transforms.headerToValue.headers=Changed
transforms.headerToValue.fields=source.changed_fields
transforms.headerToValue.operation=copy

headers and fields are lists in the same order. operation=move removes the header from the record; operation=copy keeps it.

Event changes: which columns did an update touch?

The legacy Bookshop application rewrites the whole BOOK row on every save, and a nightly job touches LAST_UPD on thousands of rows. The new book table does not have a LAST_UPD column, so most of those update events change nothing that LegacyBookTranslator cares about. io.debezium.transforms.ExtractChangedRecordState compares before and after of each update and adds headers that list the changed and the unchanged fields. The consumer can then skip events whose Changed header contains only LAST_UPD.

Adding Changed and Unchanged headers to BOOK update events
transforms=changes
transforms.changes.type=io.debezium.transforms.ExtractChangedRecordState
transforms.changes.header.changed.name=Changed
transforms.changes.header.unchanged.name=Unchanged
transforms.changes.predicate=isBookTopic
predicates=isBookTopic
predicates.isBookTopic.type=org.apache.kafka.connect.transforms.predicates.TopicNameMatches
predicates.isBookTopic.pattern=legacy\\.BOOKSHOP\\.BOOK

Behaviour to know:

  • Without the two header.* options the SMT adds nothing; set at least one.

  • Inserts, deletes and snapshot reads get empty lists.

  • The comparison needs a full before image. For Oracle that means supplemental logging for all columns (ALTER TABLE ... ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS), as described on Oracle Connector. With only primary key logging, before is incomplete and every column looks changed.

  • It is supported for the SQL connectors only. For MongoDB, apply it after the relational mapping SMT (see Event Flattening).

  • Event flattening can use the Unchanged header to drop the unchanged fields from the value (drop.fields.header.name), which gives you partial-update records.

Schema change event filter

When the source connector writes schema change events to a topic (include.schema.changes=true), every DDL on the legacy schema reaches consumers of that topic. A TRUNCATE or DROP issued during a legacy maintenance window should not trigger anything in the new system. io.debezium.transforms.SchemaChangeEventFilter drops schema change events of the listed types; the connector’s own schema history is not affected.

Hiding DROP and TRUNCATE schema change events
transforms=dropDdl
transforms.dropDdl.type=io.debezium.transforms.SchemaChangeEventFilter
transforms.dropDdl.schema.change.event.exclude.list=DROP,TRUNCATE

The valid values are CREATE, ALTER, DROP, TRUNCATE and DATABASE. How schema changes themselves should be handled during the migration is the subject of Handling Schema Changes.

Enforce record size

A legacy row with a large VARCHAR2(32767) extended string or a LOB can produce a change event bigger than the broker’s message.max.bytes or the producer’s max.request.size, and the connector task fails. io.debezium.transforms.EnforceRecordSize estimates the serialized size and, when it is too large, truncates the large string and bytes columns of before and after in proportion to their size.

Truncating records that would exceed 1 MB after compression
transforms=maxSize
transforms.maxSize.type=io.debezium.transforms.EnforceRecordSize
transforms.maxSize.max.bytes=1048576
transforms.maxSize.compression.ratio=0.6
transforms.maxSize.min.field.size=25000

max.bytes is required. compression.ratio (default 1.0) scales the estimate when the producer compresses, and min.field.size (default 25000 bytes) protects smaller fields from truncation. The estimate is approximate (one byte per character), so leave a margin.

For a migration, truncation means the new database receives different data from the legacy database. Use this SMT only for columns the new system does not migrate, or as a last resort, and prefer the S3 large message post processor, which offloads the value instead of cutting it.

Timezone converter

io.debezium.transforms.TimezoneConverter converts the time-based fields of an event to a target time zone, for every table or for selected tables and fields (include.list and exclude.list are mutually exclusive). Use a geographic zone such as Europe/Madrid rather than a fixed offset when daylight saving time applies. Fields of the source block, such as source.ts_ms, are converted only when the rule names them with the source prefix.

Presenting the ORDERS timestamps of change events in Europe/Madrid time
transforms=tz
transforms.tz.type=io.debezium.transforms.TimezoneConverter
transforms.tz.converted.timezone=Europe/Madrid
transforms.tz.include.list=source:ORDERS

The SMT assumes that the values are in UTC and converts them to the target zone. That is the opposite of the usual legacy problem. Oracle DATE has no time zone, the legacy Bookshop application stored local wall-clock time in ORDER_DT, and Debezium emits that wall-clock value as if it were UTC. Converting it "to" Europe/Madrid would shift it a second time. To turn legacy local times into correct timestamptz values, interpret them in the legacy zone where you map the type: in LegacyOrderProjector, or with a custom converter at the source. The options are compared on Data Types & Precision. Use TimezoneConverter when the values really are UTC and a consumer needs them in a local zone.

Spatial, time-series, message, vector and graph transformations

These transformations are specialised. Each one solves a type or shape mismatch between a particular source and target.

Geometry format transformer

io.debezium.transforms.GeometryFormatTransformer converts fields of the io.debezium.data.Geometry logical type between WKB and EWKB. PostGIS uses EWKB, which embeds the SRID; MySQL, SQL Server and Oracle use WKB. Set format=EWKB when moving spatial data into PostGIS. format defaults to WKB.

Converting geometries to EWKB for a PostGIS target
transforms=geometry
transforms.geometry.type=io.debezium.transforms.GeometryFormatTransformer
transforms.geometry.format=EWKB
Swap geometry coordinates

io.debezium.transforms.SwapGeometryCoordinates swaps the axis order (longitude/latitude versus latitude/longitude) of geometries whose SRID is in srids (default 4326,3857, 4269, as listed on the official page). Use it when the source and the target disagree about the axis order of the same SRID.

Swapping the axis order for SRID 4326 only
transforms=swap
transforms.swap.type=io.debezium.transforms.SwapGeometryCoordinates
transforms.swap.srids=4326
TimescaleDB integration

A TimescaleDB hypertable is stored in many chunk tables in the _timescaledb_internal schema, so the PostgreSQL connector emits one topic per chunk. io.debezium.connector.postgresql.transforms.timescaledb.TimescaleDb reassembles them into <target.topic.prefix>.<schema>.<hypertable> (default prefix timescaledb) and adds headers such as __debezium_timescaledb_chunk_table. Because an SMT cannot reach the connector’s connection, it needs its own database.hostname, database.port (default 5432), database.user, database.password and database.dbname, plus schema.list (default _timescaledb_internal). Compressed chunks are not processed.

TimescaleDB SMT settings on a PostgreSQL connector
{
  "schema.include.list": "_timescaledb_internal",
  "transforms": "timescaledb",
  "transforms.timescaledb.type": "io.debezium.connector.postgresql.transforms.timescaledb.TimescaleDb",
  "transforms.timescaledb.database.hostname": "timescaledb",
  "transforms.timescaledb.database.port": "5432",
  "transforms.timescaledb.database.user": "debezium",
  "transforms.timescaledb.database.password": "dbz",
  "transforms.timescaledb.database.dbname": "metrics"
}
Decode logical decoding message content

PostgreSQL applications can write a message straight into the WAL with pg_logical_emit_message(), without a table. The PostgreSQL connector emits it as an op: "m" event whose content is binary. io.debezium.connector.postgresql.transforms.DecodeLogicalDecodingMessageContent decodes the content into an after struct, changes op to c and drops the key, so that other SMTs, including the outbox event router, can process it. fields.null.include (default false) keeps fields with null values.

Decoding logical decoding messages on the PostgreSQL connector
{
  "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
  "transforms": "decode",
  "transforms.decode.type": "io.debezium.connector.postgresql.transforms.DecodeLogicalDecodingMessageContent",
  "transforms.decode.fields.null.include": "false"
}
Vector to JSON

MySQL vector and PostgreSQL vector, halfvec and sparsevec columns become Debezium vector logical types. io.debezium.transforms.VectorToJsonConverter turns them into io.debezium.data.Json strings, which a target without a vector type (Oracle before 23ai, SQL Server, Db2) stores in a JSON or long text column. It has no options.

Converting vector fields to JSON
transforms=vectortojson
transforms.vectortojson.type=io.debezium.transforms.VectorToJsonConverter
Neo4j CUD converter

io.debezium.transforms.Neo4jCudConverter converts change events into the CUD format that the Neo4j Kafka sink understands, for migrations from a relational database to a graph. Each table is mapped under table.<table_name>.* to nodes (node.mode=node, the default) or to relationships (node.mode=relationship, for join tables), and foreign key columns can produce relationships. output.mode=array (default) emits node and relationship events together in one record, which then needs a split step; output.mode=single emits one event per record, which the Neo4j sink reads directly but loses the relationships of node.mode=node. Table names are matched exactly and case-sensitively against source.table, so for the Oracle connector they are upper case.

Mapping BOOK and AUTHOR to a graph
transforms=neo4j
transforms.neo4j.type=io.debezium.transforms.Neo4jCudConverter
transforms.neo4j.table.AUTHOR.node.labels=Author
transforms.neo4j.table.AUTHOR.node.id.properties=AUTHOR_ID
transforms.neo4j.table.BOOK.node.labels=Book
transforms.neo4j.table.BOOK.node.id.properties=BOOK_ID
transforms.neo4j.table.BOOK.relationship.AUTHOR_ID.type=WRITTEN_BY
transforms.neo4j.table.BOOK.relationship.AUTHOR_ID.target.label=Author
transforms.neo4j.table.BOOK.relationship.AUTHOR_ID.target.id=AUTHOR_ID
Vitess transformations (incubating connector)

The Vitess connector is incubating. Its four SMTs reduce the size of its events: UseLocalVgtid keeps only the VGTID of the shard where the change happened, RemoveField and ReplaceFieldValue (option fields_names, plus field_value for the replacement) remove or shorten redundant fields, and FilterTransactionTopicRecords drops the records written to the transaction topic. They are in the io.debezium.connector.vitess.transforms package and work only with io.debezium.connector.vitess.VitessConnector.

Keeping only the local VGTID in Vitess events
transforms=useLocalVgtid
transforms.useLocalVgtid.type=io.debezium.connector.vitess.transforms.UseLocalVgtid

What goes wrong, and how to check

Symptom Likely cause and fix

The task fails with a NullPointerException or DataException from an SMT right after start-up

The SMT runs on heartbeats, schema change events or tombstones. Add a predicate or topic.regex, or set null.handling.mode.

ClassNotFoundException: io.debezium.transforms.Filter (or ContentBasedRouter)

The scripting JAR is not in this connector’s plug-in directory, or ENABLE_DEBEZIUM_SCRIPTING is not true in the Debezium image.

Unable to find script engine or a ScriptException naming the language

The JSR 223 engine (Groovy or GraalVM JavaScript JARs) is missing from the same plug-in directory, or language has no jsr223. prefix.

A filter silently drops everything

The expression throws or returns a non-boolean for some records. Test it on a sample event first, and check the column’s type (INT64, string or Decimal) on the event, not in the legacy DDL.

Events for one key arrive out of order in a consumer

Content-based routing split one table over several topics, or partition routing uses a partition.topic.num that does not match the topic.

Two rows overwrite each other in a merged topic

key.enforce.uniqueness=false on tables whose keys are not unique across tables.

A sink rejects records after a schema registry subject change

Topic routing changed the key schema name. Use schema.name.adjustment.mode=avro and plan the subject change.

Errors raised by a source-side SMT are handled by the connector’s errors.tolerance (default none: the task fails). Do not set errors.tolerance=all on a migration source connector, because a skipped record is a lost change. See Troubleshooting & Failure Recovery.

To verify a transformation:

  1. Check that the worker has the classes. GET http://localhost:8083/connector-plugins?connectorsOnly=false lists the transformations and predicates the worker can load.

  2. Validate the configuration before creating the connector, with PUT http://localhost:8083/connector-plugins/io.debezium.connector.oracle.OracleConnector/config/validate.

  3. Change one row in the legacy database and read the output topic with a console consumer that prints headers, partitions and keys, as shown in Getting Started: First Change Events.

  4. For filters and routers, count the events per topic before and after enabling the SMT for a known set of changes. Testing CDC Pipelines shows how to automate this with Testcontainers.

Listing the transformations and predicates that the Connect worker can load
curl -s 'http://localhost:8083/connector-plugins?connectorsOnly=false' \
  | jq -r '.[] | select(.type == "transformation" or .type == "predicate") | .class' | sort