Building a Medallion architecture with ClickHouse
The Medallion architecture's bronze, silver and gold tiers can be built entirely from native ClickHouse features instead of Spark and Delta Lake. Bronze uses insert-optimized MergeTree tables with the JSON type, materialized columns and TTL, fed by S3Queue, ClickPipes or Kafka. Silver is populated by incremental materialized views with dead-letter routing and ReplacingMergeTree for deduplication and CDC, which requires FINAL at query time. Gold uses refreshable materialized views for joins and denormalization, plus AggregatingMergeTree for precomputed aggregates, at the cost of data replication and extra pipeline management.
Related posts
- Building a Medallion architecture for Bluesky data with ClickHouse
ClickHouse mediumAdept
A Medallion pipeline (Bronze, Silver, Gold) in ClickHouse ingests and cleans the high-volume Bluesky Jetstream feed, which arrives with malformed JSON, inconsistent and invalid timestamps, recursive structures and frequent duplicates. Events are pulled with websocat into gzipped CSV files on GCS, then loaded into a Bronze ReplacingMergeTree table through S3Queue in ordered mode. The Bronze table uses the new JSON type with SKIP clauses to drop recursive paths. Materialized columns derive a consistent event timestamp per event kind and a cityHash64 dedup hash that excludes the crawl time. The design also accounts for most duplicates arriving within a 20-minute window, and the resulting tiers are publicly queryable at sql.clickhouse.com.
- Building a product analytics solution with ClickHouse
ClickHouse mediumAdept
ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created_at. A single sparse table avoids join overhead, since ClickHouse's sparse serialization makes empty columns cheap. Columns used for cohorts and filters should be top-level rather than buried in a JSON payload. Incremental materialized views speed up the few dozen recurring queries, and a custom SDK handles event capture.
- ClickHouse Release 23.12
ClickHouse mediumAdept
ClickHouse 23.12 adds experimental Refreshable Materialized Views, which periodically re-run an arbitrary query and atomically replace the results in a target table. That makes complex multi-join aggregations practical where incremental insert-trigger views fall short, and they can also serve as cron-style import/export jobs chained with DEPENDS. In the IMDB example, a refreshable view cuts an actor-summary query from 1.2 s to 3 ms. The release also speeds up SELECT ... FINAL by splitting data into non-intersecting sorting-key ranges, which are processed in parallel without merge logic, so only intersecting ranges pay the merge cost and merges are skipped across partitions when the partition key is a prefix of the sorting key.
- Chaining Materialized Views in ClickHouse
ClickHouse mediumAdept
ClickHouse materialized views can be chained so that one view reads from a table populated by another, rather than having several views all read from the same Kafka engine table. Using the Wikimedia recent-changes stream, the walkthrough ingests raw events from Kafka into a MergeTree table and builds per-minute aggregation states (uniqState, sumState) in an AggregatingMergeTree. It then adds a 10-minute rollup view that reads those states with -MergeState combinators. The new view only picks up rows ingested after it is created, so older data has to be backfilled with an INSERT ... SELECT, and queries finish with -Merge combinators.
- Goldsky - A Gold Standard Architecture with ClickHouse and Redpanda
ClickHouse mediumAdept
Goldsky streams blockchain data to potentially thousands of customer ClickHouse clusters by indexing chains into per-data-type Redpanda topics (Avro, infinite retention via tiered storage), applying per-customer FlinkSQL filters, joins and aggregations in stream at up to 500k events/sec, and delivering results to ClickHouse. Backfills use a custom hybrid Flink source that reads history from ClickHouse and increments from Redpanda. The main ClickHouse lesson was tuning ReplacingMergeTree for duplicates and updates: emulating PREWHERE, partitioning, limiting FINAL threads and customer-specific ORDER BY keys. The Base chain dataset (over 1B trace rows, roughly 1 TiB uncompressed) is publicly queryable at sql.clickhouse.com.