ClickhouseExplainer
@clickhouse/rowbinary: when your library is also a parser compiler
Summary
ClickHouse's @clickhouse/rowbinary is a Node.js reader and writer for the RowBinary, RowBinaryWithNames, and RowBinaryWithNamesAndTypes formats, offering both a generic parser and an accompanying Agent Skill. RowBinary avoids per-row overhead but is difficult to consume in JavaScript because nested types, LEB128 varints, precision-sensitive DateTime64 values, and recursive self-describing types require extensive runtime dispatch; JSON alternatives can also round large UInt64 values. The package provides small, composable, monomorphizable reading primitives, while SKILL.md instructs a coding agent to assemble query-specific parsers with inlined operations and selected policies such as BigInt handling and array materialization. Generated parsers run 1.5–3.4x faster than composing library functions in loops, with a fixed-width benchmark parser reaching 3.41x faster, and produce reviewable source that can be tested and benchmarked like ordinary application code.
Context
RowBinary is efficient for retrieving ClickHouse data, but consuming it from JavaScript is difficult because each leaf type has a distinct read pattern, complex types can nest arbitrarily, and generic type-dispatched readers incur runtime dispatch costs. The source also states that JSON formats can silently round UInt64 values beyond Number.MAX_SAFE_INTEGER unless a slower stringify-and-reparse path is used.
Approach / What changed
The package combines type-specific, composable reading primitives with an Agent Skill in SKILL.md. A coding agent reads the library and its comments, then generates a parser specialized to a query's exact column types, including inlined fixed-width reads, baked-in Decimal scale handling, UUID lookup-table formatting, and configurable choices such as BigInt versus number and array materialization. The generic parser, writers, and streaming variants remain available.
Takeaways
The library supports RowBinary, RowBinaryWithNames, and RowBinaryWithNamesAndTypes, with full-buffer and chunked-stream reading variants plus writers.
For a fixed-width orders schema, the generated parser performs one bounds check for a 26-byte row and reads columns at constant offsets.
The generated parser is regular source code intended for human review, testing, and benchmarking; Haiku's reported pass rate improved from 52% to 86% with focused sub-agents.
Source and freshness
- Source
- clickhouse.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.