Documentation Index
Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Write data to ClickHouse for high-performance analytical queries. Tables are created automatically with aReplacingMergeTree engine that deduplicates rows on the primary key.
Configuration
Parameters
Must be
clickhouseThe transform or source to read data from
ClickHouse table name. Created automatically if it doesn’t exist. The database is taken from the secret (see Secret Format).
Primary key column. Used as the
ORDER BY key of the created table and as the deduplication key for ReplacingMergeTree. For composite keys, pass a comma-separated list (e.g. block_number,id).Name of the Goldsky secret containing ClickHouse connection details
Number of rows to batch before flushing to ClickHouse.
Maximum time to wait before flushing a batch. Accepts a duration string (e.g.
1s, 500ms).Number of parallel writers used when sending batches to ClickHouse.
When
true (default), the table is created as ReplacingMergeTree(insert_time, is_deleted) and an is_deleted column is automatically derived from _gs_op. Deletes are handled by the merge process.When false, the table is created as a plain ReplacingMergeTree(). Upserts use INSERT, and deletes are issued as ALTER TABLE ... DELETE statements.Column used as the version argument to
ReplacingMergeTree. When not set, an insert_time DateTime DEFAULT now() column is added automatically. When set, the named column must already exist in the input schema. Only applies in append_only_mode: true.Optional per-column type overrides applied at table creation, mapping column name to a raw ClickHouse type expression (e.g.
timestamp: "DateTime64(3)", updated_at: "DateTime64(3) CODEC(Delta, ZSTD)"). Useful for narrowing types or adding codecs.Secret Format
Create a ClickHouse secret withgoldsky secret create and select the clickHouse type. The secret stores the following fields:
| Field | Description |
|---|---|
url | ClickHouse HTTPS endpoint, e.g. https://host:8443 |
username | ClickHouse user |
password | ClickHouse password |
databaseName | Database the sink will write to |
databaseName.table. The database is configured in the secret, not in the sink YAML.
Behavior
- Auto table creation: The sink creates the destination table on startup using
CREATE TABLE IF NOT EXISTS. - Engine:
ReplacingMergeTree(insert_time, is_deleted)by default,ReplacingMergeTree()whenappend_only_mode: false. ORDER BY: theprimary_keycolumn(s).- Deduplication: handled by ClickHouse merges. To read the latest version of each row, query with
SELECT ... FROM table FINALor use theFINALmodifier in ClickHouse’s query settings. - Deletes (
_gs_op = 'd'): in the default mode, rows are markedis_deleted = 1and cleaned up by merges. Inappend_only_mode: false, deletes are issued asALTER TABLE ... DELETE. - Type conversion: Arrow types are mapped to ClickHouse types automatically. Use
schema_overrideto customize any column.