---
title: "How to use Rust in ClickHouse: avoiding a full rewrite"
description: "ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting."
url: "https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4"
canonical: "https://clickhouse.com/blog/alexey-p99-2025-rust-in-clickhouse"
source: "ClickHouse"
published: "2025-12-17"
difficulty: "medium"
kind: "Case study"
reading_minutes: 13
tags: ["rust","c-cpp","build-systems","refactoring","testing"]
---

# How to use Rust in ClickHouse: avoiding a full rewrite

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-12-17, 13 min read, Case study. Original: [https://clickhouse.com/blog/alexey-p99-2025-rust-in-clickhouse](https://clickhouse.com/blog/alexey-p99-2025-rust-in-clickhouse)

## Summary

ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting. It started with Corrosion to wire Rust into CMake and a BLAKE3 hash function, then took on a client history-navigation feature, the PRQL query language, and Databricks' delta-kernel-rs for Delta Lake support. The integration problems were mostly practical: hermetic reproducible builds with vendored crates, buggy FFI wrappers caught quickly by existing CI and fuzzing, library panics that crash the server, compiling Rust with sanitizers (now easier with an MSan toolchain), duplicated cross-compilation setup, and transitive dependencies linking system OpenSSL.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- C++ build systems ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- Rust basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- sanitizers and fuzzing ([easy posts on Vulnerability research](https://swe.quest/tags/vulnerability-research.md?difficulty=easy))

## Keywords

ClickHouse, Corrosion, CMake, BLAKE3, PRQL, delta-kernel-rs, Delta Lake, OpenSSL

## Related posts

- [A Year of Rust in ClickHouse](https://swe.quest/articles/a-year-of-rust-in-clickhouse-fadc1c7501c80398.md): ClickHouse · 2025-04-01 · Medium · 12 min read · Rust, C & C++, Build systems, Testing, Supply chain security
  ClickHouse added Rust to its C++ codebase as an option for new components rather than a rewrite, starting with BLAKE3, then skim for clickhouse-client history, PRQL as a switchable query dialect, and Databricks' delta-kernel-rs replacing a sketchy C++ Delta Lake implementation.
- [More Than 2x Faster Hashing in ClickHouse Using Rust](https://swe.quest/articles/more-than-2x-faster-hashing-in-clickhouse-using-rust-404bde5cc500d24b.md): ClickHouse · 2022-10-25 · Medium · 5 min read · Rust, C & C++, Build systems, Performance engineering, Cryptography
  ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file.
- [Integrating the Rust Delta Kernel into ClickHouse](https://swe.quest/articles/integrating-the-rust-delta-kernel-into-clickhouse-4dfcdd8e64024cda.md): ClickHouse · 2026-05-22 · Hard · 17 min read · Analytics & OLAP, Rust, C & C++, Build systems, Data pipelines
  ClickHouse replaced its hand-written Delta Lake protocol implementation with the Rust Delta Kernel (delta-kernel-rs).
- [chDB - A Rocket Engine on a Bicycle](https://swe.quest/articles/chdb-a-rocket-engine-on-a-bicycle-951148e84c12126b.md): ClickHouse · 2023-09-29 · Hard · 9 min read · Analytics & OLAP, Memory management, C & C++, Python, Performance engineering
  chDB embeds the ClickHouse engine as an in-process Python module instead of shelling out to the 500MB clickhouse-local binary, using WriteBufferFromVector, Python memoryview and Pybind11 for zero-copy result retrieval.
- [Fuzzing ClickHouse](https://swe.quest/articles/fuzzing-clickhouse-2e19ad8301dd21c4.md): ClickHouse · 2021-03-11 · Medium · 8 min read · Testing, Databases, Vulnerability research, CI/CD
  ClickHouse's AST-based query fuzzer takes SQL queries from the regression test suite, parses them, and randomly mutates the AST.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
