Skip to content

fix!: port the v2.0 sketch fixes to v1.5 - #15

Merged
rustyconover merged 1 commit into
v1.5from
fix/port-sketch-fixes-v1.5
Oct 27, 2026
Merged

rustyconover merged 1 commit into
v1.5from
fix/port-sketch-fixes-v1.5

Conversation

@rustyconover

Copy link
Copy Markdown
Collaborator

Ports the behaviour fixes from #13 and #14 to v1.5. The codegen refactor stays on v2.0, because v1.5's codegen has diverged too far to share it.

  • K validation against what each library accepts: Quantiles (powers of 2, 2–32768), KLL (8–65535), TDigest (10–65535; K above 65535 used to be truncated) and REQ (4–1024). REQ needs the library patch in the vcpkg overlay, because the library kept K in 8 bits (256 became 4); sent upstream as fix: req_sketch truncated k to 8 bits apache/datasketches-cpp#552. Theta's lg_k was cast to uint8_t unchecked and is now validated.
  • CPC keeps its HIP estimator when combining an empty partial state.
  • Bounds for HLL, CPC and Theta validate num_std_devs.
  • Corrupt sketches in Theta and Frequent Items report "Failed to deserialize … sketch" instead of a raw library error.
  • Frequent Items:
    • The get_frequent error type is case-insensitive and rejects invalid values; anything but the exact 'NO_FALSE_NEGATIVES' used to silently mean NO_FALSE_POSITIVES.
    • A NULL lg_max_k is now an error.
  • Casts to sketch_hll, sketch_cpc, sketch_theta and sketch_frequent_items give the sketch type instead of BLOB.
  • Breaking: every sketch aggregate returns NULL when it has no input rows. Previously Theta and Frequent Items returned an empty sketch. Merging only empty sketches still returns an empty sketch.

Built on linux_arm64 against DuckDB 1.5. The full suite passes (866 assertions), and the UUID/HUGEINT parallel checks from #11 pass 30/30.

🤖 Generated with Claude Code

Ports the fixes from #13 and #14 (the codegen refactor stays on v2.0):

- K is validated against the range each library accepts. Quantiles needs a
  power of 2 from 2 to 32768, KLL 8 to 65535, TDigest 10 to 65535 (K above
  65535 was truncated), REQ 4 to 1024. REQ's library kept K in 8 bits, so
  K of 256 or more wrapped around (256 became 4); the vcpkg overlay now
  patches that (apache/datasketches-cpp#552). Theta's lg_k was cast to
  uint8_t unchecked; it is now validated.
- CPC keeps its HIP estimator when combining an empty partial state.
- HLL, CPC and Theta bounds validate num_std_devs (1, 2 or 3) instead of
  failing with a raw library error.
- Theta and Frequent Items report corrupt sketches as "Failed to
  deserialize ... sketch" instead of a raw library error.
- datasketch_frequent_items_get_frequent's error type is case-insensitive
  and rejects other values (anything but the exact 'NO_FALSE_NEGATIVES'
  silently meant NO_FALSE_POSITIVES); a NULL lg_max_k is an error.
- Casts to sketch_hll, sketch_cpc, sketch_theta and sketch_frequent_items
  have the sketch type instead of BLOB.
- Every sketch aggregate returns NULL when it has no input rows.

BREAKING CHANGE: datasketch_theta, datasketch_frequent_items and
datasketch_frequent_items_weighted over no rows return NULL instead of an
empty sketch (use coalesce(..., 0) on an estimate for the old result), and
K values that used to be accepted but misbehaved are now bind errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rustyconover
rustyconover merged commit 373616a into v1.5 Oct 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant