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.
Metadata
Release files for onestep-clickhouse 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| onestep_clickhouse-0.1.1.tar.gz | 11.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| onestep_clickhouse-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.2 kB
Release files / onestep_clickhouse-0.1.1.tar.gz
| Download URL | onestep_clickhouse-0.1.1.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
012067e216e600325214f60bbd7cca88e08514f3b6f49561d29a61eb09f8777c
|
|
BLAKE2b-256 checksum How to use checksums |
9224fa694e62cf0989d989d47ecb30365f6d04b7a6a4dabe471248b28925076c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / onestep_clickhouse-0.1.1-py3-none-any.whl
| Download URL | onestep_clickhouse-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9c9c14eb30bd50b2c0476d4549020f10c847b28652bdf66cbc166c3e5af9770
|
|
BLAKE2b-256 checksum How to use checksums |
53d568150d5084526f6bf1e4aed3cef7c86aa17818c6a1cddbbfaf35d1b498c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Security for onestep-clickhouse 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.