The ClickZetta adapter plugin for dbt
Project description
dbt-clickzetta
The dbt adapter for ClickZetta Lakehouse.
See the examples/ directory for complete, runnable examples of all features.
Installation
pip install dbt-clickzetta
Requires Python 3.8+ and dbt-core 1.8+.
Quickstart
1. Configure profiles.yml
my_project:
target: dev
outputs:
dev:
type: clickzetta
service: cn-shanghai-alicloud.api.clickzetta.com
instance: your_instance
workspace: your_workspace
username: your_username
password: your_password
schema: your_schema
vcluster: default_ap
2. Test connection
dbt debug
3. Run your project
dbt run
dbt test
dbt docs generate
Supported Features
| Feature | Supported |
|---|---|
table materialization |
✅ |
view materialization |
✅ |
incremental materialization |
✅ |
ephemeral materialization |
✅ |
snapshot (SCD Type 2) |
✅ |
dynamic_table materialization |
✅ |
materialized_view materialization |
✅ |
dbt test (generic + singular) |
✅ |
dbt seed |
✅ |
dbt docs generate |
✅ (row count, size, last modified) |
dbt source freshness |
✅ |
persist_docs (relation + columns) |
✅ |
| Partitioned tables | ✅ |
| Clustered tables | ✅ |
| Python models | ✅ |
on_schema_change |
✅ (append_new_columns, sync_all_columns) |
grants |
✅ |
clone materialization |
✅ (zero-copy clone + Time Travel clone) |
| Indexes (Bloomfilter / Inverted / Vector) | ✅ (auto-created via indexes config) |
| Table Stream as source | ✅ (declare in sources.yml, reference via source()) |
| VCluster per-model | ✅ (via vcluster config) |
Incremental Strategies
| Strategy | Description |
|---|---|
merge (default) |
MERGE INTO with unique_key |
append |
INSERT INTO without deduplication |
insert_overwrite |
INSERT OVERWRITE with dynamic partition mode |
delete+insert |
DELETE matching keys then INSERT, suitable for partition replacement without a primary key |
{{ config(
materialized='incremental',
incremental_strategy='merge',
unique_key='id'
) }}
Indexes
Supports Bloomfilter, Inverted, and Vector index types. Indexes are created automatically after the table is built:
{{ config(
materialized='table',
indexes=[
{'type': 'bloomfilter', 'columns': ['order_id']},
{'type': 'inverted', 'columns': ['status'], 'analyzer': 'unicode'},
{'type': 'vector', 'columns': ['embedding'], 'distance_function': 'cosine_distance', 'scalar_type': 'f32'}
]
) }}
VCluster per-model
Assign a specific VCluster to a model for compute resource isolation:
{{ config(
materialized='table',
vcluster='large_ap' -- this model runs on the large_ap cluster
) }}
Utility Macros
Run via dbt run-operation:
# Compact small files (useful after high-frequency incremental writes)
dbt run-operation optimize_table --args '{relation: my_schema.my_table}'
dbt run-operation optimize_table --args '{relation: my_schema.my_table, where: "dt >= current_date() - interval 7 days"}'
# Switch VCluster for the current session
dbt run-operation use_vcluster --args '{vcluster: large_ap}'
# List recently dropped objects available for recovery
dbt run-operation show_tables_history --args '{schema: my_schema}'
# Recover a dropped object (table, dynamic table, materialized view, or stream)
dbt run-operation undrop --args '{relation: my_schema.my_table}'
# Drop an object (type: table | view | dynamic_table | materialized_view | stream)
dbt run-operation drop_object --args '{relation: my_schema.my_table, type: table}'
# Manually refresh a dynamic table
dbt run-operation refresh_dynamic_table --args '{model_name: my_dynamic_table}'
Dynamic Table
{{ config(
materialized='dynamic_table',
refresh_interval='5 minutes',
refresh_vc='default_ap'
) }}
select id, name, amount
from {{ ref('orders') }}
After creation, the table is automatically refreshed once (equivalent to Snowflake's initialize=ON_CREATE). Subsequent refreshes run on the configured interval.
Snapshot
Snapshots use standard dbt SCD Type 2 via MERGE INTO on regular tables (no delta/iceberg required).
{% snapshot orders_snapshot %}
{{ config(
target_schema='snapshots',
unique_key='id',
strategy='timestamp',
updated_at='updated_at'
) }}
select * from {{ source('raw', 'orders') }}
{% endsnapshot %}
Connection Parameters
| Parameter | Required | Description |
|---|---|---|
type |
✅ | Must be clickzetta |
service |
✅ | API endpoint, e.g. cn-shanghai-alicloud.api.clickzetta.com |
instance |
✅ | Instance name |
workspace |
✅ | Workspace name |
username |
✅ | Username |
password |
✅ | Password |
schema |
✅ | Default schema |
vcluster |
✅ | VCluster name, e.g. default_ap |
connect_retries |
❌ | Connection retry count (default: 3) |
Development
# Clone
git clone https://github.com/clickzetta/dbt-clickzetta.git
cd dbt-clickzetta
# Install in editable mode
pip install -e .
# Run unit tests
pip install pytest
pytest tests/unit/
# Run functional tests (requires a real Lakehouse connection)
cp test.env.example test.env
# Fill in test.env with your connection details
pytest tests/functional/
License
Apache 2.0
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_clickzetta-1.6.2.tar.gz.
File metadata
- Download URL: dbt_clickzetta-1.6.2.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7398b896acd9875e85d35dc9beab3485c9a4aa838b653aa86205a7d5025d5273
|
|
| MD5 |
924c90086d3f449dbd4ee614e4b7005e
|
|
| BLAKE2b-256 |
adc976a17641a03ccfccf5f2bb1efdeea4fef66fbc042c0fd3e9bfe56808deed
|
Provenance
The following attestation bundles were made for dbt_clickzetta-1.6.2.tar.gz:
Publisher:
release.yml on clickzetta/dbt-clickzetta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_clickzetta-1.6.2.tar.gz -
Subject digest:
7398b896acd9875e85d35dc9beab3485c9a4aa838b653aa86205a7d5025d5273 - Sigstore transparency entry: 1670626014
- Sigstore integration time:
-
Permalink:
clickzetta/dbt-clickzetta@ca3c19248605fed0a507dfdcc6ce00e9e2827d53 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/clickzetta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ca3c19248605fed0a507dfdcc6ce00e9e2827d53 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dbt_clickzetta-1.6.2-py3-none-any.whl.
File metadata
- Download URL: dbt_clickzetta-1.6.2-py3-none-any.whl
- Upload date:
- Size: 39.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
933c7e4dd32187f5cf1d0e2ba3ce5d47b9e545decff5c21dc8f2c0fa446dacb2
|
|
| MD5 |
021717517a5da118a3efccc8bacc6349
|
|
| BLAKE2b-256 |
63ca68f3fe071d089749e4e72c1290caaa1fae458cff1726366f071a396aa4b6
|
Provenance
The following attestation bundles were made for dbt_clickzetta-1.6.2-py3-none-any.whl:
Publisher:
release.yml on clickzetta/dbt-clickzetta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_clickzetta-1.6.2-py3-none-any.whl -
Subject digest:
933c7e4dd32187f5cf1d0e2ba3ce5d47b9e545decff5c21dc8f2c0fa446dacb2 - Sigstore transparency entry: 1670626307
- Sigstore integration time:
-
Permalink:
clickzetta/dbt-clickzetta@ca3c19248605fed0a507dfdcc6ce00e9e2827d53 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/clickzetta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ca3c19248605fed0a507dfdcc6ce00e9e2827d53 -
Trigger Event:
workflow_dispatch
-
Statement type: