onestep-clickhouse
onestep-clickhouse provides an acknowledged asynchronous ClickHouse table sink
for onestep. It inserts rows into an existing
table; it does not create or migrate ClickHouse schema.
Installation
pip install onestep-clickhouse
Python 3.9 or newer and onestep>=1.7.1 are required.
Python usage
from onestep_clickhouse import ClickHouseConnector
clickhouse = ClickHouseConnector(
dsn="https://writer:secret@clickhouse:8443/analytics",
client_options={
"connect_timeout": 10,
"send_receive_timeout": 30,
},
)
sink = clickhouse.table_sink(
table="events",
columns=("event_id", "occurred_at", "kind", "payload"),
batch_size=1000,
settings={"async_insert": 0},
)
The connector creates its async client lazily on the first insert. A connector closes a client it created, while a client injected by an application remains owned by the caller. Closing a connector is idempotent.
Strict YAML usage
apiVersion: onestep/v1alpha1
kind: App
app:
name: clickhouse-writer
resources:
analytics:
type: clickhouse
dsn: "${CLICKHOUSE_DSN}"
client_options:
connect_timeout: 10
send_receive_timeout: 30
events:
type: clickhouse_table_sink
connector: analytics
table: events
columns: [event_id, occurred_at, kind, payload]
batch_size: 1000
settings:
async_insert: 0
tasks: []
Validate long-lived configuration with onestep check --strict worker.yaml.
The dsn and client_options catalog fields are secret metadata and are not
included in topology descriptors.
Rows and columns
Each sink send accepts one mapping or an explicitly non-empty sequence of mappings. Strings, empty sequences, mixed sequences, and non-mapping items are rejected before the first network call.
When columns is configured, every row must contain exactly those keys. Values
are ordered according to the configured column sequence. When columns is
omitted, the first mapping's insertion order fixes the columns for that logical
send, and every later mapping must have exactly the same key set. The plugin does
not infer database schema or coerce values.
batch_size defaults to 1000 rows. A larger logical batch is split into chunks,
and each chunk is inserted and awaited sequentially. The sink has no timer,
hidden flush queue, or cross-send batching, so task concurrency and the
ClickHouse client pool provide the concurrency controls. Tune task concurrency
and client pool limits together for the server's capacity.
Acknowledged async inserts
A successful send means every chunk received an acknowledged server response.
Fire-and-forget async inserts are rejected. If async_insert is enabled, the
settings must also include wait_for_async_insert: 1:
settings:
async_insert: 1
wait_for_async_insert: 1
This awaited contract applies direct backpressure: onestep does not acknowledge the source delivery until the selected sink finishes.
Delivery and duplicate semantics
The sink awaits every ClickHouse insert chunk and has no hidden queue. A crash after
ClickHouse acknowledges a chunk but before onestep acknowledges the source can
duplicate rows. A later chunk failure is reported as uncertain because earlier
chunks remain committed. Idempotency depends on table design; use stable event keys
and a dedup-aware engine such as ReplacingMergeTree when duplicates matter.
Multi-sink fan-out is not transactional. If a later sink fails, ClickHouse writes from an earlier successful sink call are not rolled back. An explicit task retry may repeat already committed rows or chunks.
For example, a table can retain a stable event key and version for eventual replacement:
CREATE TABLE events
(
event_id String,
version DateTime64(3),
payload String
)
ENGINE = ReplacingMergeTree(version)
ORDER BY event_id;
This is deployment guidance only. The plugin does not execute DDL or generate a deduplication token, and ClickHouse replacement behavior depends on the chosen engine and query strategy.
Deferred features
The first release does not include automatic timed coalescing, DDL or migrations, query sources, streaming formats, Arrow or DataFrame APIs, schema inference or coercion, distributed-table routing, plugin-generated deduplication tokens, mutations, or upserts.
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 onestep_clickhouse-0.1.0.tar.gz.
File metadata
- Download URL: onestep_clickhouse-0.1.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebdb394ed0d28ef1459361a706f386a94e43c54e1a98962b07b3b31869798b51
|
|
| MD5 |
2bcedb3e01f9af723c78857c1faeb66a
|
|
| BLAKE2b-256 |
d6aed343322ab429406365a1794016f8aff98b5443013a9b1058228fb2c252fb
|
File details
Details for the file onestep_clickhouse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: onestep_clickhouse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b7fa2c9457ae94492e1ec383d4f408979baa88f0cd00c2a87a53cb731885f30
|
|
| MD5 |
ad3bbe7f9bc8bfb827f19dad68b12e4c
|
|
| BLAKE2b-256 |
edb445250703f0d47a7a5f577824e2e01b1bf6ef5969e3bab0c487f91d95b29a
|