---
title: "Fuzzing ClickHouse"
description: "ClickHouse's AST-based query fuzzer takes SQL queries from the regression test suite, parses them, and randomly mutates the AST."
url: "https://swe.quest/articles/fuzzing-clickhouse-2e19ad8301dd21c4"
canonical: "https://clickhouse.com/blog/fuzzing-click-house"
source: "ClickHouse"
published: "2021-03-11"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["testing","databases","vulnerability-research","ci-cd"]
---

# Fuzzing ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2021-03-11, 8 min read, Case study. Original: [https://clickhouse.com/blog/fuzzing-click-house](https://clickhouse.com/blog/fuzzing-click-house)

## Summary

ClickHouse's AST-based query fuzzer takes SQL queries from the regression test suite, parses them, and randomly mutates the AST. It swaps in bad numeric values such as NaN and integer limits, perturbs strings and arrays, and splices function arguments, expressions and tables from other test queries. The core is about 700 lines of C++ and has found more than 200 bugs, including segfaults and logic errors. Much of that comes from pairing it with assertions, a distinct LOGICAL\_ERROR exception for internal bugs, and clang sanitizers. In CI it weights permutations toward new tests in pull requests and needs settings constraints, since it once disabled its own execution-time limit.

Written by swe.quest, not by the author.

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

## Topics

- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Vulnerability research](https://swe.quest/tags/vulnerability-research.md) (Security)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- abstract syntax trees
- fuzzing concepts ([easy posts on Vulnerability research](https://swe.quest/tags/vulnerability-research.md?difficulty=easy))

## Keywords

ClickHouse, AST-based fuzzing, SQLSmith, SQLancer, AddressSanitizer, property-based testing

## Related posts

- [BuzzHouse: Bridging the database fuzzing gap for testing ClickHouse](https://swe.quest/articles/buzzhouse-bridging-the-database-fuzzing-gap-for-testing-clickhouse-7d42aa00b0761971.md): ClickHouse · 2025-01-21 · Medium · 8 min read · Testing, Databases, Analytics & OLAP, SQL
  BuzzHouse is a new ClickHouse fuzzer that generates complex but mostly semantically valid SQL backed by a tracked catalog of tables, filling a gap left by SQLsmith, SQLancer, the AST fuzzer and WINGFUZZ.
- [Fuzzing collaboration with WINGFUZZ - Part 1](https://swe.quest/articles/fuzzing-collaboration-with-wingfuzz-part-1-659c66e435090a2d.md): ClickHouse · 2023-08-08 · Easy · 4 min read · Testing, Vulnerability research, Databases, Analytics & OLAP
  WINGFUZZ, a DBMS fuzzing engine, found eight new bugs in ClickHouse, some introduced only four months earlier, using two techniques.
- [Decorating a Christmas Tree With the Help Of Flaky Tests](https://swe.quest/articles/decorating-a-christmas-tree-with-the-help-of-flaky-tests-286b59f771e1aae7.md): ClickHouse · 2021-12-27 · Medium · 3 min read · Testing, CI/CD, Concurrency
  ClickHouse treats flaky tests as bugs to investigate rather than noise to mute or retry, and deliberately makes tests flakier to surface hidden issues.
- [Testing the Performance of ClickHouse](https://swe.quest/articles/testing-the-performance-of-clickhouse-9f67306f19e976df.md): ClickHouse · 2021-08-19 · Medium · 11 min read · Performance engineering, Testing, CI/CD, Analytics & OLAP
  ClickHouse catches performance regressions in CI by running the reference and patched servers side by side on the same machine and alternating about 3000 end-to-end test queries between them.
- [Fuzzer Blind Spots (Meet Jepsen!)](https://swe.quest/articles/fuzzer-blind-spots-meet-jepsen-95901ab1fc56e123.md): TigerBeetle · 2025-06-06 · Hard · 7 min read · Testing, Formal methods, Storage engines, Query engines, Debugging
  Jepsen found a missing-results bug in TigerBeetle's query engine despite four fuzzers covering it, because the VOPR and LSM query fuzzer pre-registered disjoint queries whose matching objects were always consecutive in every secondary index, so zig-zag merge join probing was never exercised.

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)
