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 ( |
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 ( |
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 |
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.
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 |
|
Merge several physical tables (archive tables, shards, partitions) into one topic. |
Content-based routing |
|
Send some events of a table to a different topic, based on their content. |
Message filtering |
|
Drop events that the new system must not receive. |
New record state extraction |
|
Flatten the envelope for non-Debezium sinks. See Event Flattening. |
MongoDB new document state extraction |
|
The MongoDB counterpart. See Event Flattening. |
MongoDB relational mapping |
|
Project MongoDB documents to fixed relational columns. See Event Flattening. |
Event changes |
|
Add headers that list the changed and unchanged fields of an update. |
Outbox event router |
|
Publish domain events from an outbox table. See Outbox Event Router. |
MongoDB outbox event router |
|
The MongoDB counterpart. |
Schema change event filtering |
|
Hide |
Partition routing |
|
Choose the partition from payload fields, for example all lines of one order on one partition. |
HeaderToValue |
|
Move or copy headers into the record value. |
Timezone converter |
|
Convert timestamp fields to a target time zone. |
Geometry format transformer |
|
Convert geometries between WKB and EWKB. |
Swap geometry coordinates |
|
Swap the axis order of geometries for selected SRIDs. |
TimescaleDB integration |
|
Reassemble hypertable chunks into one logical topic. |
Decode logical decoding message content |
|
Turn a PostgreSQL logical decoding message into a structured, insert-like event. |
Vector to JSON |
|
Write vector columns to a target database without a vector type. |
Neo4j CUD converter |
|
Feed a relational-to-graph migration through the Neo4j Kafka sink. |
Enforce record size |
|
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 |
|
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
nullvalue. 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.
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
Reference: Debezium — Defining SMT predicates
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.
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
Reference: Debezium — Ignoring tombstone events
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_2024andORDERS_ARCH_2025; the running Bookshop example does not have them, but many legacy schemas do). -
Sharded schemas, where
shard1.customersandshard2.customersform 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.
{
"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 |
|---|---|---|
|
none |
Regular expression that selects the topics to re-route. |
|
none |
Destination topic. Can refer to groups of |
|
|
Add a field to the key so that keys from different tables cannot collide. |
|
|
Name of the added key field. |
|
none |
Regular expression applied to the original topic name to compute the key field value. |
|
none |
Value of the key field, in terms of the groups captured by |
|
|
|
|
|
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.ContentBasedRouterevaluatestopic.expression. A non-null string result is the new topic name;nullkeeps the default topic. -
io.debezium.transforms.Filterevaluatescondition.truekeeps the record;falsedrops 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:
-
The SMT itself:
debezium-scripting-3.7.1.Final.tar.gzfrom 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. -
A JSR 223 script engine for the language. Debezium does not ship one.
-
Groovy needs
groovy,groovy-jsr223and, if you parse JSON in expressions,groovy-json. The Maven coordinates areorg.apache.groovy:groovy,org.apache.groovy:groovy-jsr223andorg.apache.groovy:groovy-json. The Debezium 3.7.1.Final BOM pins them at4.0.17. -
GraalVM JavaScript needs
graalvm.jsandgraalvm.js.scriptengine. The Debezium 3.7.1.Final BOM usesorg.graalvm.js:js-languageandorg.graalvm.js:js-scriptengineat25.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.
-
-
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.
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
Reference: Debezium — Filter SMT set up
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.
{
"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"
}
Reference: Debezium — Filter SMT configuration options
How the pieces fit:
-
The predicate restricts the filter to the
CUSTOMERtopic, so the other tables, heartbeats and schema change events are not evaluated. -
CUST_IDis aNUMBER(10). The Bookshop source usesdecimal.handling.mode=string, so the Oracle connector emits it as a string ("70"), and the Groovy expression converts it withas Longbefore% 10; a bare% 10on the string would fail. With theprecisedefault it would be anINT64, andas Longis then a no-op (see Data Types & Precision). -
A delete event has
after == null, which is why the expression readsbeforeforop == 'd'. -
null.handling.mode=keeppasses tombstones through without evaluating the expression. The other values aredropandevaluate.
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 |
|---|---|
|
|
|
|
JavaScript with another JSR 223 engine |
Use the |
|
Set |
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.
{
"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
4711before 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_CDisVARCHAR2(2), so the comparison is a plain string comparison. ACHARcolumn 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:
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
Reference: Debezium — Filter SMT language specifics
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.
{
"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.Xandbefore.Xselect a specific image; the special prefixchangeusesafterfor creates and updates andbeforefor 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) ormurmur(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.
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.
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
beforeimage. 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,beforeis 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
Unchangedheader 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.
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.
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.
transforms=tz
transforms.tz.type=io.debezium.transforms.TimezoneConverter
transforms.tz.converted.timezone=Europe/Madrid
transforms.tz.include.list=source:ORDERS
Reference: Debezium — Timezone converter options
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.GeometryFormatTransformerconverts fields of theio.debezium.data.Geometrylogical type between WKB and EWKB. PostGIS uses EWKB, which embeds the SRID; MySQL, SQL Server and Oracle use WKB. Setformat=EWKBwhen moving spatial data into PostGIS.formatdefaults toWKB.Converting geometries to EWKB for a PostGIS targettransforms=geometry transforms.geometry.type=io.debezium.transforms.GeometryFormatTransformer transforms.geometry.format=EWKB - Swap geometry coordinates
-
io.debezium.transforms.SwapGeometryCoordinatesswaps the axis order (longitude/latitude versus latitude/longitude) of geometries whose SRID is insrids(default4326,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 onlytransforms=swap transforms.swap.type=io.debezium.transforms.SwapGeometryCoordinates transforms.swap.srids=4326Reference: Debezium — Swap geometry coordinates options
- TimescaleDB integration
-
A TimescaleDB hypertable is stored in many chunk tables in the
_timescaledb_internalschema, so the PostgreSQL connector emits one topic per chunk.io.debezium.connector.postgresql.transforms.timescaledb.TimescaleDbreassembles them into<target.topic.prefix>.<schema>.<hypertable>(default prefixtimescaledb) and adds headers such as__debezium_timescaledb_chunk_table. Because an SMT cannot reach the connector’s connection, it needs its owndatabase.hostname,database.port(default5432),database.user,database.passwordanddatabase.dbname, plusschema.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" }Reference: Debezium — TimescaleDB integration options
- 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 anop: "m"event whosecontentis binary.io.debezium.connector.postgresql.transforms.DecodeLogicalDecodingMessageContentdecodes the content into anafterstruct, changesoptocand drops the key, so that other SMTs, including the outbox event router, can process it.fields.null.include(defaultfalse) keeps fields withnullvalues.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
vectorand PostgreSQLvector,halfvecandsparseveccolumns become Debezium vector logical types.io.debezium.transforms.VectorToJsonConverterturns them intoio.debezium.data.Jsonstrings, 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 JSONtransforms=vectortojson transforms.vectortojson.type=io.debezium.transforms.VectorToJsonConverterReference: Debezium — Vector to JSON example
- Neo4j CUD converter
-
io.debezium.transforms.Neo4jCudConverterconverts 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 undertable.<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=singleemits one event per record, which the Neo4j sink reads directly but loses the relationships ofnode.mode=node. Table names are matched exactly and case-sensitively againstsource.table, so for the Oracle connector they are upper case.Mapping BOOK and AUTHOR to a graphtransforms=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:
UseLocalVgtidkeeps only the VGTID of the shard where the change happened,RemoveFieldandReplaceFieldValue(optionfields_names, plusfield_valuefor the replacement) remove or shorten redundant fields, andFilterTransactionTopicRecordsdrops the records written to the transaction topic. They are in theio.debezium.connector.vitess.transformspackage and work only withio.debezium.connector.vitess.VitessConnector.Keeping only the local VGTID in Vitess eventstransforms=useLocalVgtid transforms.useLocalVgtid.type=io.debezium.connector.vitess.transforms.UseLocalVgtidReference: Debezium — Vitess use local VGTID
What goes wrong, and how to check
| Symptom | Likely cause and fix |
|---|---|
The task fails with a |
The SMT runs on heartbeats, schema change events or tombstones. Add a predicate or |
|
The scripting JAR is not in this connector’s plug-in directory, or |
|
The JSR 223 engine (Groovy or GraalVM JavaScript JARs) is missing from the same plug-in directory, or
|
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 ( |
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 |
Two rows overwrite each other in a merged topic |
|
A sink rejects records after a schema registry subject change |
Topic routing changed the key schema name. Use |
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:
-
Check that the worker has the classes.
GET http://localhost:8083/connector-plugins?connectorsOnly=falselists the transformations and predicates the worker can load. -
Validate the configuration before creating the connector, with
PUT http://localhost:8083/connector-plugins/io.debezium.connector.oracle.OracleConnector/config/validate. -
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.
-
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.
curl -s 'http://localhost:8083/connector-plugins?connectorsOnly=false' \
| jq -r '.[] | select(.type == "transformation" or .type == "predicate") | .class' | sort
Reference: Apache Kafka 4.3 — Kafka Connect REST API
References
-
Debezium — Using SMT predicates to selectively apply transformations
-
Debezium — Vitess use local VGTID, Vitess remove field, Vitess replace field value, Vitess filter transaction topic records
-
debezium/container-images (GitHub) —
ENABLE_DEBEZIUM_SCRIPTING -
Apache Kafka 4.3 — Kafka Connect transformations and predicates