Skip to main content

ClickHouse

The ClickHouse destination writes each stream to its own table in one ClickHouse database through the ClickHouse HTTP interface. It is a Daspire-built connector and runs on the Daspire native runtime.

A retry never writes the same data twice. A sync interrupted before it started writing is retried automatically. After that point, a sync retries by itself only when every stream in the connection uses Append and Daspire proves that none of its rows reached your tables. Any other interrupted sync (for example, its rows landed but the commit was not yet confirmed) pauses the connection with your data left as written; contact Daspire support to resolve it.

Prerequisites​

Server​

  • A self-managed ClickHouse server, version 21.8 or later. ClickHouse Cloud is not supported yet: its databases use the Replicated engine and its tables SharedMergeTree, which this destination does not write to.
  • Network access from Daspire to the HTTP port: 8123 for HTTP or 8443 for HTTPS. The native TCP port (9000) is not used.

Target database​

Use an existing database, or create one, with the Atomic engine (the default for new databases):

CREATE DATABASE daspire ENGINE = Atomic;

Recovery tables​

Daspire records each commit in two small tables in the target database. The destination never creates tables outside your synced streams on its own, so create these once, as an administrator, before you set up the destination (replace daspire with your database). The Daspire user does not need permission to create ReplacingMergeTree tables:

CREATE TABLE daspire._daspire_commit_status_v1 (
commit_id String,
identity_json String,
committed_at DateTime64(3, 'UTC')
) ENGINE=ReplacingMergeTree(committed_at)
ORDER BY commit_id;

CREATE TABLE daspire._daspire_commit_stage_v1 (
commit_id String,
request_digest String,
stream_hash String,
stage_table String,
record_count UInt64,
data_digest String,
ready_at DateTime64(3, 'UTC')
) ENGINE=ReplacingMergeTree(ready_at)
ORDER BY (commit_id, stream_hash);

The connection test fails until both tables exist with exactly these columns.

User and permissions​

Create a dedicated user for Daspire:

CREATE USER daspire_writer IDENTIFIED BY '<strong-password>';
GRANT ALL ON daspire.* TO daspire_writer;
-- Newer ClickHouse versions also require an explicit table-engine grant
-- (skip this line if your server reports a syntax error for it):
GRANT TABLE ENGINE ON MergeTree TO daspire_writer;

The user creates, renames, drops and alters tables in the target database, and inserts and deletes rows.

Optionally, also grant SELECT ON system.processes (needed only on servers that restrict system tables). Daspire then also checks for a still-running earlier write before it retries an interrupted append. Retries are safe without it.

Features​

FeatureSupported?
Full Refresh – OverwriteYes
Full Refresh – AppendYes
Incremental – AppendYes
Incremental – Append + DedupedNot yet
NamespacesNo: every stream is written to the configured database

Overwrite​

Each sync replaces the table's contents in one atomic step. Because it removes earlier data, overwrite must be allowed explicitly with Allow overwrite.

Append​

Each sync adds its rows in one atomic step: readers see either none or all of a sync's rows.

Append writes to plain MergeTree tables (the tables the destination creates). A stream whose existing table uses ReplicatedMergeTree can only use Overwrite.

Append keeps every record, so rows that a source sends again (for example the rows at an incremental source's saved cursor value) appear more than once. Deduplicate them in your queries, for example with LIMIT 1 BY on your key.

Append + Deduped​

Not supported yet. A connection that selects it fails before writing anything.

Output schema​

Each stream is written to a table named _airbyte_raw_<stream>. Characters other than letters, digits and _ become _, and the name is lower-cased. Each table has three columns:

ColumnTypeContent
_airbyte_ab_idStringA unique ID for the row
_airbyte_dataStringThe record as a JSON object
_airbyte_emitted_atDateTime64(3, 'GMT')When the source emitted the record

These names match tables written by earlier versions of the ClickHouse destination, so existing tables keep working. Use ClickHouse's JSON functions, for example JSONExtractString(_airbyte_data, 'email'), to read fields.

Setup guide​

You need the following information to configure the destination:

FieldDescription
HostHost name or IP address. Do not include http://, a port or a path.
PortHTTP port: 8123 for HTTP, 8443 for HTTPS.
DatabaseThe Atomic database that holds the recovery tables.
UsernameThe ClickHouse user.
PasswordThe user's password.
SSLConnect over HTTPS with certificate verification.
Allow overwriteMust be on for streams that use Overwrite.

SSH tunnels and JDBC URL parameters are not supported.