MongoDB SMT for BSON unwrapping

4 views
Skip to first unread message

Sumit Jha

unread,
Nov 8, 2025, 10:03:46 PM (4 days ago) Nov 8
to debezium
Hello Team,

I am using the Debezium MongoDB connector 3.2.1.Final and facing an issue when attempting to flatten BSON data types (like $oid, $date) into native types using SMT.

Current Behavior (Without SMTs):
Without any SMTs applied, the data is successfully ingested into Kafka and subsequently consumed by a Snowflake sink connector. However, fields retain their verbose BSON wrappers in the output payload (e.g., "_id": {"$oid": "..."}, "createdAt": {"$date": "..."})

Desired Behavior (With SMTs):
I want these fields flattened so that _id appears as a plain string, and dates/longs appear as their respective native types. For this, I am using the standard ExtractNewDocumentState SMT:

transforms: unwrap
transforms.unwrap.type: io.debezium.connector.mongodb.transforms.ExtractNewDocumentState
transforms.unwrap.add.fields: op,ts_ms,source.ts_ms

The Problem:
With the ExtractNewDocumentState SMT enabled, the connector fails repeatedly with following DataException errors:

<error screenshot attached>

My Question:
How can I automatically unwrap the BSON types ($oid, $date, $numberLong, etc.) into simple scalar types (String, Long, Timestamp) across all fields (including deeply nested ones) without causing DataException with ExtractNewDocumentState due to schema drift in my source MongoDB collections?



errors.png
configs.png
Reply all
Reply to author
Forward
0 new messages