Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 16 min read Deep dive mediumAdept

Consuming the Delta Lake Change Data Feed for CDC

Delta Lake's Change Data Feed (CDF) can drive CDC into ClickHouse by reading row-level change events reconstructed from the _delta_log transaction log and the _change_data Parquet files. Appends appear as add actions with min/max stats used for data skipping. Updates produce update_preimage/update_postimage rows and deletes produce single delete rows. On the ClickHouse side, rows land in a ReplacingMergeTree keyed on _commit_version so background merges resolve the latest state eventually, with FINAL queries for immediate correctness and soft-delete caveats. ClickHouse also releases an MIT-licensed Python reference implementation built on delta-rs and DataFusion that polls version ranges and categorizes CDC/add/remove actions.

Assumes: change data capture conceptsParquet and object storageClickHouse MergeTree enginesdata lakehouse table formats

Related posts

  • Change Data Capture (CDC) with PostgreSQL and ClickHouse - Part 1

    ClickHouse mediumAdept

    Postgres-to-ClickHouse CDC can be built by streaming row changes from Postgres logical decoding (pgoutput plugin, replication slots, LSN ordering) through Debezium and Kafka, then applying them in ClickHouse with the ReplacingMergeTree engine. Updates and deletes become immutable inserts carrying a version column and a deleted flag, and background merges collapse duplicates. Correct results before a merge require FINAL at query time. Consumers must tolerate duplicate events after restarts, and deleted rows are only purged when clean_deleted_rows is set to Always, a setting with a known bug as of 23.5. The post also compares pull-based and push-based CDC and explains why a Kafka queue protects the Postgres WAL from growing when ClickHouse is unavailable.

  • How Spyne simplified their CDC pipeline with ClickPipes and ClickHouse Cloud

    ClickHouse mediumAdept

    Spyne replaced a self-managed Debezium → Kafka → ClickHouse Kafka-engine/materialized-view CDC pipeline with ClickPipes on ClickHouse Cloud. The move eliminated 1–1.5 hours of manual work per table onboarding and fixed schema drift, where new source columns were silently dropped by DDL-locked materialized views. It also brought tradeoffs: snapshotting a new table pauses the whole pipe, so critical tables were isolated into dedicated pipes. ReplacingMergeTree's eventual consistency required adding FINAL to queries at extra CPU cost, and binlog loss forces full table resyncs instead of targeted partial ones.

  • Postgres CDC in ClickHouse, A year in review

    ClickHouse mediumAdept

    A year after PeerDB's acquisition, Postgres CDC into ClickHouse via ClickPipes has grown to 400+ companies replicating over 200 TB per month, driven by real-time customer-facing analytics and data warehousing workloads. Key engineering changes include keeping logical replication connections open, because reconnects re-read WAL from restart_lsn and spiked lag. CTID block-based partitioning cut initial-load partition generation from 7+ hours to under a second, and 50+ pre-flight checks plus bucketed user-facing alerts cut on-call load by orders of magnitude. The biggest remaining gap is data modeling overhead from ReplacingMergeTree's asynchronous deduplication, which ClickHouse plans to address with lightweight UPDATEs and unique indexes.

  • Change Data Capture (CDC) with PostgreSQL and ClickHouse - Part 2

    ClickHouse mediumAdept

    A Postgres-to-ClickHouse CDC pipeline is built with Debezium, Kafka Connect and a ClickHouse materialized view, keeping a ReplacingMergeTree table in sync with the 28M-row UK property price dataset under a mix of inserts, updates and deletes. Key configuration choices include REPLICA IDENTITY FULL (required for delete support), the pgoutput logical decoding plugin, per-row ordering via a single or hash-partitioned Kafka topic, and version/deleted columns in the ReplacingMergeTree engine. The ORDER BY is chosen for analytical access patterns, with the Postgres id appended last for uniqueness. The initial load uses the postgresql table function via INSERT INTO SELECT, which loads all 28M rows in about 80 seconds without tuning but requires pausing writes; Debezium's consistent snapshot is the alternative.

  • Streamkap: An out-of-the-box CDC solution for ClickHouse

    ClickHouse mediumAdept

    Streamkap's ClickHouse connector streams change data capture from PostgreSQL, MySQL, SQL Server, Oracle and MongoDB into ClickHouse using Kafka, Debezium and Flink. It maps Kafka Connect types, including nested structs and arrays, to ClickHouse types such as Tuple and Array, and adds metadata columns like op type, source timestamp and delete flag to every row. Append mode writes every change to MergeTree tables, while the default upsert mode uses ReplacingMergeTree keyed on the event timestamp and a delete flag, so queries need FINAL to get deduplicated results. The post also covers handling inconsistent semi-structured source data and choosing between blocking and incremental snapshots for the initial load.

The quest for software engineering knowledge.

Look:
Layout: