Skip to main content

Bugs we found in DuckDB, ClickHouse, and NumPy aggregate functions

· 2 min read

What we're building​

We have been developing writePath over the past year focused on providing customers with:

  1. Sub-millisecond aggregations over the first or last N rows of their data with no pre-computation
  2. Precise aggregation functions validated against reference implementations and exact math
  3. A simple AWS Marketplace experience allowing control through APIs

What we found​

During development we used reference implementations from vendors and packages such as DuckDB, ClickHouse, and NumPy to validate aggregate correctness.

We found bugs within the reference implementations falling into one of 3 main categories: Rounding, Range, and Logic.

CategoryReference implementation bugHow writePath addresses it
RoundingDigits rounded during accumulation are lostValues are accumulated exactly and rounded once at the end
RangeNumbers exceed type constraints resulting in overflow or wraparoundIntegers stay integers and intermediate results never overflow when the true answer fits
LogicThe wrong rule is applied for constant data, infinities, zero or negative weights, or empty inputEvery edge case has a defined rule that is documented per function and validated against reference implementations and exact math

How we report bugs​

Since these are not security bugs, our approach is to submit each bug to the vendor through proper channels and then post our findings here.

After each submission and post, we will add another entry to the table at the bottom of this post.

About Us​

writePath is an AWS Marketplace SaaS for sub-millisecond aggregations over the first or last N rows of your data with no pre-computation. It offers 65 high-precision aggregation functions tested against reference implementations.

www.thewritepath.net

All Vendor Bugs​

VendorFunctionBug Submission LinkBlog PostDate
DuckDBfavgduckdb/duckdb#27961DuckDB favg returns the wrong average when values differ greatly in magnitudeOctober 27, 2026