Debezium × Tableflow: Iceberg Before the Columns Exist
Local MySQL CDC into a Confluent Cloud Tableflow topic, materialized as Iceberg on ADLS Gen2 and queried in Snowflake Horizon, with no local Kafka brokers.
Overview
You want a warehouse table of live MySQL rows, and Tableflow has to be on before Debezium has seen a single column. That is the wrong order for ordinary CDC, and it is exactly the constraint this demo is built around.
Tableflow cannot enable on a schemaless topic. Debezium does not know
the mydb.team columns until the connector starts. So Terraform plants a
generic value-only Avro schema (tableflow.Value with optional tf_bootstrap),
sets that subject to FORWARD, and turns Tableflow on. Then a local Connect
worker, talking SASL_SSL to Confluent Cloud, unwraps CDC rows, forces every
field optional, and auto-registers the live columns onto that same value
subject. Snowflake Horizon reads the Iceberg table. There are no local Kafka
brokers.
The Terraform lives in DebziumConfluentTableFlowIcebergSnowflakeNoSMT. It is a sibling of the Datagen-to-Horizon wiring in Tableflow × Snowflake: same catalog path, different producer, and a schema-evolution problem Datagen never has.
How it works
Three decisions keep Tableflow RUNNING instead of suspended:
- Bootstrap first. Terraform registers
nosmt_mydb_team-valueas Avrotableflow.Valuewith one optional field,tf_bootstrap. No key schema. Then it enables Tableflow Iceberg on ADLS Gen2. - FORWARD, subject-only. The registry’s global default stays BACKWARD. Only this value subject is overridden so a later producer can add fields while Tableflow’s existing table keeps reading.
- Every CDC field optional. Stock Connect transforms unwrap the envelope,
drop deletes, flatten so ancestor optionality lands on every leaf (including
MySQL
NOT NULLcolumns), and re-inserttf_bootstrapforever. Keys stay JSON, out of Schema Registry.
MySQL (Docker)
│ binlog CDC
▼
Kafka Connect + Debezium ──SASL_SSL──► Confluent Cloud nosmt_mydb_team
Tableflow already enabled
│
▼
Iceberg on ADLS Gen2
│
▼
Snowflake NOSMT_TABLEFLOW_DB.CONFLUENT.NOSMT_MYDB_TEAM
What it demonstrates
- Tableflow before the table schema. Version 1 is a placeholder, not a copy
of
mydb.team. The first CDC record becomes v2 (id,name,email,last_modified, all optional, plustf_bootstrap). AnALTER TABLE … ADD COLUMNbecomes v3 the same way. - Registry vs Tableflow. FORWARD lets the extra optional fields through
Schema Registry. Optionality is what keeps Iceberg alive: a required-field
Avro version suspends Tableflow even if the subject is
NONEand the schema stored. Deletingtf_bootstrapsuspends it too. - Why not ExtractNewRecordState. Debezium’s usual unwrap SMT rebuilds the
value schema through
copySchemaBasics(), which dropsoptional. Flatten then has nothing to propagate, MySQLNOT NULLcolumns register as required, and Tableflow suspends witha required field was added at 'id'.ExtractField$Valueonafterkeeps the flag. - Cloud cluster, local worker. Connect bootstraps the Confluent Cloud
cluster. Compose runs MySQL 8.1 and
cp-kafka-connect7.6.5 with Debezium MySQL 2.5.4.topic.delimiter=_publishes straight tonosmt_mydb_team, so there is noRegexRouter.
Technical details
- Stack: Terraform (
confluentinc/confluent2.57,azurerm~3.80,azuread,snowflakedb/snowflake~2.0). Docker Compose for MySQL + Connect. Iceberg on ADLS Gen2. Snowflake Horizon catalog integration against Tableflow IRC. - Value-only Avro:
key.converteris JSON with schemas disabled. A required Avro key becomes Icebergkey_*columns and suspends Tableflow the same way a required value field does. - Transform chain:
unwrap(ExtractField$Value/after) →dropdeletes(tombstones: Tableflow APPEND suspends on null values) →flatten(optionality, not nested paths) →tfb(InsertFieldoftf_bootstrapwith an emptystatic.value). All of these are on Confluent Cloud’s allowed list. - Snowflake query:
NOSMT_TABLEFLOW_DB.CONFLUENT.NOSMT_MYDB_TEAM.AUTO_REFRESHpolls IRC every 30s; Tableflow’s commit cadence is the real wait, typically 3–6 minutes from insert to visible row. - Honest constraint: this FORWARD + all-optional + placeholder pattern is for when you cannot register the table schema before Tableflow. If the columns are known, or CDC can start first, use the usual BACKWARD + required first schema, then optional adds.
Challenges & lessons
-
Required fields suspend Tableflow, not just the Registry. Adding a required Avro field is at most forward compatible in Schema Registry, and it is the change that takes the Iceberg table down.
NONEis not a workaround: Tableflow applies its own rule on top. -
Debezium’s unwrap SMT is the trap.
ExtractNewRecordStatelooks like the right tool and is the one that breaks this path. Measured on Debezium 2.5.4 / Kafka 3.6: after that SMT, leaf fields are required. AfterExtractField$Value, they stay optional withdefault: null. -
tf_bootstrapis not scaffolding. Dropping it suspends the table (the field 'tf_bootstrap' was deleted). Schema Registry under FORWARD would allow the drop. Tableflow will not. Thetfbtransform has to re-add the column on every record, forever, and it must run afterflatten. -
Deletes must never reach the topic. A delete envelope has
after == null, so unwrap emits a null value. Tableflow in APPEND mode suspends on those.dropdeletesplusinclude.schema.changes=falsekeep non-row records off the topic. -
Do not swap the storage account in place. Terraform will plan it, then fail with both halves destroyed and a one-hour grace period before Tableflow can re-enable. Destroy and apply a new environment. Pick a globally unique name you have not used recently, or Snowflake resolves metadata and then fails to download Parquet.
-
Destroy can 409 on the Azure provider integration. Once the cluster is gone, Confluent still reports the integration in use.
terraform state rm confluent_provider_integration_setup.azurethen destroy again; deleting the environment removes anything still inside it.