clickhouse-rs

Official async Rust client for ClickHouse with typed rows and schema validation

SDK
Cargo
v0.15.2
560 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
68 /100 Good
Development Activity 76
Maintenance 36
Community 72
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 85
Code Quality 88
Innovation 84
Learning Curve 78

clickhouse-rs (crate name clickhouse) is the official pure-Rust client for ClickHouse, the column-oriented analytical database. It maps rows to native Rust structs via serde, communicates over HTTP using the RowBinaryWithNamesAndTypes wire format by default, and validates struct field names and types against the live ClickHouse schema so mismatches surface as clear errors instead of silent corruption.

Beyond basic select/insert, the crate provides an Inserter for infinite buffered inserts with byte/row/time thresholds, LZ4/LZ4HC/ZSTD compression, TLS via rustls or native-tls, mock testing utilities, and optional integrations with uuid, time, chrono, and OpenTelemetry context propagation. It is maintained directly by ClickHouse Inc. and is the de facto standard driver for talking to ClickHouse from async Rust services built on Tokio and Hyper.

What You Get

  • Typed select/fetch API that deserializes rows into serde-derived structs, with placeholder binding (?, ?fields) for parameterized queries
  • An Inserter for infinite/buffered inserts with configurable byte, row, and time-based flush thresholds
  • RowBinaryWithNamesAndTypes wire format by default, giving schema-validated errors instead of opaque NotEnoughData failures
  • Built-in compression (LZ4, LZ4HC, ZSTD) and pluggable TLS (native-tls or rustls, including custom root stores)
  • Mock server utilities (test-util feature) for unit-testing query and insert logic without a live ClickHouse instance
  • Optional uuid, time, chrono, and OpenTelemetry-context feature flags for common data types and distributed tracing

Common Use Cases

  • Streaming analytics events or logs from a Tokio-based Rust service into ClickHouse in real time
  • Building infinite background inserters that batch rows by size, count, or time window before flushing
  • Running parameterized analytical queries from a Rust backend and mapping results directly to domain structs
  • Writing integration tests against ClickHouse behavior using the crate’s mock client instead of a live server

Under The Hood

Architecture - The crate centers on a Client that issues HTTP requests to a ClickHouse server via hyper/hyper-util, serializing bound query parameters and streaming RowBinaryWithNamesAndTypes-encoded responses through a rowbinary decoder into caller-defined structs; the Inserter (src/inserter.rs) wraps insert.rs to batch rows and flush on byte/row/time thresholds, while cursors/ handles the async streaming decode loop and sql/ builds parameterized query text. Tech Stack - Built on Tokio and Hyper 1.x for async HTTP, serde/serde_json for row (de)serialization, bytes for zero-copy buffers, optional rustls/native-tls for TLS and lz4_flex/zstd for compression, with a small internal workspace of clickhouse-macros (the #[derive(Row)] proc-macro) and clickhouse-types for schema type modeling. Code Quality - The repo has an extensive tests/it/ integration suite covering compression, TLS, nested types, cursors, mocks, and edge cases like Int256/bfloat16, plus tests/ui compile-fail tests for the derive macro, clippy.toml/rustfmt.toml lint configs, and CI with codecov coverage tracking — a mature, well-tested codebase for a 48-contributor project. API Design - The client API favors ergonomic builder chaining (Client::default().with_url(..).with_user(..)) and query placeholders (?, ?fields) resolved against struct fields, with schema validation surfacing mismatches as descriptive errors by default rather than opaque binary decode failures, at a small, well-documented performance cost that can be opted out of.

Used by 5 apps in this directory

C++
68%
Apache 2.0

ClickHouse

Analytics · Data Engineering · Databases

50,116

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
64
Dependency
Built with
C++ 68%
Python 14%
Updated 5 days ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 6 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 5 days ago
Rust
64%
Apache 2.0

Temps

Analytics · Devops · Monitoring

801

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
70
Dependency
Built with
Rust 64%
TypeScript 34%
Updated 5 days ago
Rust
71%
MIT

Trieve

AI Development · Developer Tools · Search

2,719

All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.

View details
42
Repo Health
74
Technical
64
Dependency
Built with
Rust 71%
Updated 8 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers