Skippr is now Manifold.

Skip to content

ClickHouse ​

Use ClickHouse when that is already your analytics store. Mfd inserts batches into database.table. A retry can write a batch again, so plan a unique key or a downstream dedup. See Exactly-once delivery.

Before you begin ​

  • A HTTP(S) URL for the ClickHouse service (https://host:8443).
  • A database and a user that can insert (and create the table if it does not exist).
bash
export CLICKHOUSE_PASSWORD="change-me"

Configure ​

python
from mfd import Config, DataSinkClickhouse, EnvRef, Pipeline

cfg = Config.discover()
ch = cfg.data_sink(
    "warehouse",
    DataSinkClickhouse(
        url="https://clickhouse.internal:8443",
        database="analytics",
        user="mfd",
        password=EnvRef("CLICKHOUSE_PASSWORD"),
        table="events",
    ),
)
cfg.pipeline("events", Pipeline(data_source=cfg.get_data_source("sample"), data_sink=ch))
cfg.save()
bash
mfd connect data-sink clickhouse \
  --pipeline events \
  --name warehouse \
  --url https://clickhouse.internal:8443 \
  --database analytics \
  --user mfd \
  --password '${CLICKHOUSE_PASSWORD}' \
  --table events
yaml
data_sinks:
  warehouse:
    Clickhouse:
      url: https://clickhouse.internal:8443
      database: analytics
      user: mfd
      password: ${CLICKHOUSE_PASSWORD}
      table: events

Options ​

KeyTypeRequired/DefaultDescription
urlURLRequiredClickHouse HTTP(S) endpoint
databasestringNot setDatabase; omitted uses the server default
userstringNot setUser
passwordsecretNot setPassword as ${ENV}
tablestringNot setTable name; omitted uses the pipeline namespace

How data lands ​

Snapshot batches insert as Apache Parquet over HTTP (INSERT … FORMAT Parquet). That is the only write path. Mfd creates a MergeTree table when table does not exist. Nested columns land as ClickHouse Tuple, Array, and Map (never Nullable(Array/Map/Tuple)); dates as Date32; decimals as Decimal(38, 9). Business-key columns used in ORDER BY are non-nullable.

CDC uses a ReplacingMergeTree(_mfd_version, _mfd_is_deleted) table ordered by the business key. _mfd_version packs the WAL tie as seq (32 bits), ordinal (8 bits), and row (24 bits); a value that does not fit fails closed. Deletes set _mfd_is_deleted. Query with FINAL (or wait for a merge) to see the current row. Do not run CDC against a snapshot MergeTree table. Create a separate table, or drop the snapshot table first.

A retry can write a batch again before merge. Deduplicate on your primary key, or rely on ReplacingMergeTree plus FINAL for CDC.

Troubleshooting ​

SymptomFix
Connection refusedCheck url and TLS
Authentication failedExport the password variable in this shell
Table missingGrant CREATE or create the table first
ClickHouse CDC requires ReplacingMergeTreeCDC will not write to a snapshot MergeTree table. Use a different table, or drop the snapshot table first.

Next steps ​