clickhouse-dfe
The official ClickHouse Rust client speaks HTTP and nothing else. Plenty of deployments expose port 9000 and no HTTP at all.
JSON,VariantandDynamiccolumns do not read. Inserting needs a struct known at compile time, which a loader taking arbitrary shapes off a topic does not have.
Extensions for the official client, as a separate crate depending on the
published clickhouse release. Adds a native TCP transport, runtime-schema
inserts, and one client that dispatches over either.
cargo add clickhouse clickhouse-dfe
Extension traits on the HTTP client
ping, kill_query, with_query_id, with_session_id, with_role, and
ServerException::parse for a typed error carrying the server's own code.
use Client;
use ClientExt;
# async
Native TCP
cargo add clickhouse-dfe --features tcp
Reads are column-typed, and JSON, Variant and Dynamic decode to their
per-row document text.
use TcpClient;
let client = new.with_database;
let blocks = client
.query
.fetch_blocks
.await?;
for block in &blocks
Runtime-schema inserts
cargo add clickhouse-dfe --features dynamic
Rows arrive as serde_json::Map, column types come from system.columns.
Binary on the wire either way -- FORMAT RowBinary over HTTP, FORMAT Native
over TCP -- so the server does no JSON parsing.
Features
| Feature | What it adds |
|---|---|
ext |
Extension traits on clickhouse::Client (default) |
lz4 |
LZ4 for the HTTP transport, forwarded to upstream (default) |
zstd |
Zstd for the HTTP transport, forwarded to upstream |
tcp |
Native TCP transport: connection actor, pool, retry, wire codec |
tls |
rustls trust for the TCP transport (implies tcp) |
dynamic |
Runtime-schema inserts (implies ext) |
unified |
One client over both transports (implies tcp) |
full |
All of the above |
Default is ext plus lz4, neither of which adds a dependency beyond
upstream's. tcp brings deadpool, socket2 and backon.
Documentation
| Read | When |
|---|---|
| type-support | Checking whether a column type reads and writes |
| insert-formats | Asking why there is no JSONEachRow option |
| unified-client | Choosing a transport at runtime |
| coverage | Adding to a hot-path module |
Upstream
Not a fork. The dependency on the published clickhouse release is the only
link -- no git, no path, no [patch]. Same edition, MSRV, rustfmt settings
and lint set, so
ClickHouse/clickhouse-rs can
cherry-pick from here without a reformat or a relicence.