Skip to main content

Clickhouse loader for mkpipe.

Project description

mkpipe-loader-clickhouse

ClickHouse loader plugin for MkPipe. Writes Spark DataFrames into ClickHouse tables using the native clickhouse-spark connector, which uses ClickHouse's binary HTTP protocol for efficient columnar inserts.

Documentation

For more detailed documentation, please visit the GitHub repository.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.


Connection Configuration

connections:
  clickhouse_target:
    variant: clickhouse
    host: localhost
    port: 8123
    database: target_db
    user: default
    password: mypassword

Table Configuration

pipelines:
  - name: pg_to_clickhouse
    source: pg_source
    destination: clickhouse_target
    tables:
      - name: public.events
        target_name: stg_events
        replication_method: full
        batchsize: 50000

Write Parallelism & Throughput

ClickHouse loader inherits from JdbcLoader. Two parameters control write performance:

      - name: public.events
        target_name: stg_events
        replication_method: full
        batchsize: 50000        # rows per JDBC batch insert (default: 10000)
        write_partitions: 4     # coalesce DataFrame to N partitions before writing

How they work

  • batchsize: number of rows buffered before sending a single INSERT to ClickHouse. ClickHouse benefits greatly from large batches — use 50,000–500,000 for best throughput.
  • write_partitions: calls coalesce(N) on the DataFrame before writing, reducing the number of concurrent JDBC connections. Useful when you have many Spark partitions and want to limit load on ClickHouse.

Performance Notes

  • ClickHouse is optimized for large bulk inserts. batchsize is the most impactful parameter — increase it as much as your driver memory allows.
  • Avoid many small write_partitions (e.g. 1) as it reduces parallelism. A value of 4–8 balances load and throughput.
  • ClickHouse's MergeTree engine merges parts in the background; very frequent small inserts create many parts and degrade query performance. Prefer fewer large batches.

All Table Parameters

Parameter Type Default Description
name string required Source table name
target_name string required ClickHouse destination table name
replication_method full / incremental full Replication strategy
batchsize int 10000 Rows per JDBC batch insert
write_partitions int Coalesce DataFrame to N partitions before writing
dedup_columns list Columns used for mkpipe_id hash deduplication
tags list [] Tags for selective pipeline execution
pass_on_error bool false Skip table on error instead of failing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkpipe_loader_clickhouse-0.6.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkpipe_loader_clickhouse-0.6.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mkpipe_loader_clickhouse-0.6.1.tar.gz.

File metadata

  • Download URL: mkpipe_loader_clickhouse-0.6.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for mkpipe_loader_clickhouse-0.6.1.tar.gz
Algorithm Hash digest
SHA256 0c9ea7b9e7a3888e91658e4dc0e3bbc0a719551ff9d81384618d838538821383
MD5 e393e096cbe4eea1f7125f1c835f1269
BLAKE2b-256 70a5515ced7dfb23ac952a1b3697f537b29f2691a5e3fc7f0af575203ecaa8fd

See more details on using hashes here.

File details

Details for the file mkpipe_loader_clickhouse-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkpipe_loader_clickhouse-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 269722de1d0454198474bb3f5bffb53f981b5c1922580310d541984c53fc2b4d
MD5 5d83a5a96c835d46cfb061a898b484c5
BLAKE2b-256 42d1748325231ee58bc5e7935e0f4133595c82a8e97c51a66900d8971b32b3db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page