Skip to main content
GuideServerConfigure and deploy Tabsdata servers on your machine.TutorialsConfigure data integration workflows within a running Tabsdata server.API ReferenceCLI ReferenceRelease Notes
Version: 2.3.0

ClickHouseDest

class
class ClickHouseDest(
tables: ClickHouseTableNamesSpec,
if_table_exists: IfTableExistsSpec = 'append',
schema_evolution: SchemaEvolutionSpec = 'strict',
dest_cfg: DestCfgSpec | None = None,
)

Bases: Dest

Categories: destination

ClickHouse destination for @subscriber -- one output slot per table.

Examples​

Write a table with the replace disposition -- the first run creates it, later runs drop and recreate it (row count stays):

@subscriber(
destination=ClickHouseDest(
tables=["cap_replace"],
if_table_exists="replace",
),
input_tables=["caps_input/cap_rows"],
)
def out_replace(rows: TableFrameSpec) -> TableFrameSpec:
return rows

Append rows with a wider schema and let ClickHouse evolve the table -- schema_evolution="update" adds the new column rather than failing on the mismatch ("strict" would reject it):

@subscriber(
destination=ClickHouseDest(
tables=["cap_evolve"],
if_table_exists="append",
schema_evolution="update",
),
input_tables=["caps_input/cap_evo_v2"],
)
def evolve(rows: TableFrameSpec) -> TableFrameSpec:
return rows

Parameters​

parameter

Target table names (non-empty), one write slot per entry. Each is a 1- or 2-part name (table or database.table); backtick-quote a part for special characters.

parameter
if_table_existsIfTableExistsSpec (Literal['append', 'replace'])

"append" (the default) adds rows; "replace" overwrites the table.

parameter
schema_evolutionSchemaEvolutionSpec (Literal['strict', 'update'])

What a write does when the batch's columns differ from the table's. "replace" makes the table the batch's own, so it is not affected. "strict" (the default) refuses a batch with a column the table lacks or a wider type; "update" adds the column and widens the type, and refuses a change ClickHouse cannot make. A column the batch lacks is written NULL either way.

parameter
dest_cfgDestCfgSpec | None (Mapping[Literal['clickhouse.logging_level', 'clickhouse.schema_evolution_engine'], Any] | None)

Optional connector config. Supported keys: clickhouse.logging_level, and clickhouse.schema_evolution_engine -- "iceberg", the default and only engine: ClickHouse has no schema evolution of its own.

Methods​

method
validate
def validate()

Cross-field validation: tables must be non-empty.

Called by the framework; raises ClickHouseValidateException.