The Clickhouse plugin for dbt (data build tool)
Project description
dbt-clickhouse
This plugin ports dbt functionality to Clickhouse.
We do not test over older versions of Clickhouse. The plugin uses syntax that requires version 22.1 or newer.
Installation
Use your favorite Python package manager to install the app from PyPI, e.g.
pip install dbt-clickhouse
Supported features
- Table materialization
- View materialization
- Incremental materialization
- Seeds
- Sources
- Docs generate
- Tests
- Snapshots
- Ephemeral materialization
Usage Notes
Database
The dbt model database.schema.table
is not compatible with Clickhouse because Clickhouse does not support a schema
.
So we use a simple model schema.table
, where schema
is the Clickhouse's database. Please, don't use default
database!
Model Configuration
Option | Description | Required? |
---|---|---|
engine | The table engine (type of table) to use when creating tables | Optional (default: MergeTree() ) |
order_by | A tuple of column names or arbitrary expressions. This allows you to create a small sparse index that helps find data faster. | Optional (default: tuple() ) |
partition_by | A partition is a logical combination of records in a table by a specified criterion. The partition key can be any expression from the table columns. | Optional |
unique_key | A tuple of column names that uniquely identify rows. For more details on uniqueness constraints, see here. | Optional |
inserts_only | This property is relevant only for incremental materialization. If set to True, incremental updates will be inserted directly to the target table without creating intermediate table. This option has the potential of significantly improve performance and avoid memory limitations on big updates. | Optional |
settings | A dictionary with custom settings for INSERT INTO and CREATE AS SELECT queries. | Optional |
Example Profile
your_profile_name:
target: dev
outputs:
dev:
type: clickhouse
schema: [database name]
# optional
driver: [http] # http or native. If not set will autodetermine base one port
port: [port] # default 8123
user: [user] # default 'default'
host: [db.clickhouse.com] # default localhost
password: [password] # default ''
verify: [verify] # default True
secure: [secure] # default False
connect_timeout: [10] # default 10 seconds.
custom_settings: {} # Custom seetings for the connection - default is empty.
Running Tests
This adapter passes all of dbt basic tests as presented in dbt's official docs: https://docs.getdbt.com/docs/contributing/testing-a-new-adapter#testing-your-adapter.
Note: The only feature that is not supported and not tested is Ephemeral materialization.
Tests running command:
pytest tests/integration
You can customize a few test params through environment variables. In order to provide custom params you can create test.env
file under root (remember not to commit this file!) and define the following env variables inside:
- DBT_CH_TEST_HOST - Default=
localhost
- DBT_CH_TEST_USER - your ClickHouse username. Default=
default
- DBT_CH_TEST_PASSWORD - your ClickHouse password. Default=''
- DBT_CH_TEST_PORT - ClickHouse client port. Default=8123
- DBT_CH_TEST_DATABASE - Explicit database (dbt 'schema') used to execute queries for test setup. Defaults to ClickHouse user default. Note that each test will actually generate a new random database.
- DBT_CH_TEST_DB_ENGINE - Database engine used to create schemas. Defaults to '' (server default)
- DBT_CH_TEST_USE_DOCKER - Identify whether to run clickhouse-server docker image (see tests/docker-compose.yml). Default=False. Set it to True if you'd like to raise a docker image (assuming docker-compose is installed in your machine) during tests that launches a clickhouse-server. Note: If you decide to run a docker image you should set DBT_CH_TEST_PORT to 10900 too.
Original Author
ClickHouse wants to thank @silentsokolov for creating this connector and for their valuable contributions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dbt-clickhouse-1.3.0.tar.gz
.
File metadata
- Download URL: dbt-clickhouse-1.3.0.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3339054b2da327a5d219907cce077a3016cd2ba2be6e15365c9ff56ebe25da2e |
|
MD5 | 099765be11f080b2f445bae097146db9 |
|
BLAKE2b-256 | 6bab988504075741379ec63f589e9b03dc25ecbda9ce26fed0631853b9b071bf |
File details
Details for the file dbt_clickhouse-1.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: dbt_clickhouse-1.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5884385f334f3775f823500cc0c917581ed223eb364b107918c502a1e88cbd9 |
|
MD5 | e876a2b07f54a517a29471c691cf3c85 |
|
BLAKE2b-256 | 14643959e67424eed85155a97961314f38cdb02fc6d3494574647d6ae87d9c1a |