← Back to Pull requests

deps: upgrade datasketches to 0.6.0 and drop the HLL decode workarounds #7402

Closed
unknown closed this pull request without merging on Nov 02, 2026 23:59 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 13:39 UTC
Author

Which issue does this PR close?

Closes #7395.

Rationale for this change

datasketches 0.3.0 had two HLL decode defects, and hll_sketch.rs carried a workaround for each:

  • Compact HLL array sketches lost their register block, so a decoded sketch kept its own estimate but every union built from it was wrong. Comet cleared the COMPACT flag before decoding.

  • An updatable HLL_4 sketch with auxiliary-map entries was read with the compact layout, dropping the exceptions. Comet rejected that shape with an error, so a sketch column written by DataSketches-Java with its default target type (HLL_4) failed in hll_sketch_estimate, hll_union and hll_union_agg once it held enough distinct values.
  • The crate's changelog lists fixes for both. I checked rather than trusted it, see below. 0.6.0 was released on 2026-10-29.

    What changes are included in this PR?

  • datasketches =0.3.0 to =0.6.0. Cargo.lock changes only that crate and has no new dependencies.

  • Two API changes in hll_sketch.rs: hash_value is now hash::value, and HllSketch::new / HllUnion::new return Result. SparkHllSketch::new and SparkHllUnion::new stay infallible with an expect, as the old constructors panicked on the same out-of-range lgConfigK, which the serdes already validate.

  • Removed normalize_compact_hll_array, reject_undecodable_hll4 and the preamble constants only they used.

  • Removed the HLL_4 auxiliary-map entry from getIncompatibleReasons in CometHllSketchEstimate, CometHllUnion and CometHllUnionAgg, since that input is now read correctly.

  • Replaced the two tests that pinned the rejection with tests against three sketches serialized by DataSketches-Java 6.2.0 (the version Spark 4.1 and 4.2 ship) at lgConfigK 12: HLL_4 updatable with one aux entry, HLL_4 compact with two, and HLL_6. Each test checks the decoded estimate, and the estimate of a union with a second sketch, against Java's value to within 1e-6.

  • The module pin comment in native/Cargo.toml is rewritten for the new reason to pin exactly.
  • Left alone: the layout module that sizes accumulators. estimated_size() now exists, but the changelog calls it implementation-dependent, so that is part of the HLL audit in #7396.

    How are these changes tested?

  • Native: cargo test -p datafusion-comet-spark-expr --lib hll (38 pass), and cargo clippy --workspace --all-targets -- -D warnings is clean.

  • The new fixture tests do catch the old behavior. I ran the same three fixtures through the raw 0.3.0 crate in a scratch project: both HLL_4 fixtures decode to the right estimate and a wrong union (the compact one gives 1,991,062 where Java gives 4,033,480). The HLL_6 fixture matches on both versions and is a regression guard only.

  • Before deleting the workarounds I also compared all 18 combinations of HLL_4/6/8, compact/updatable, and 1,000 / 100,000 / 2,000,000 values with Java, and sketches built in Rust and unioned after a byte round trip. All matched to within 1e-6. Those scratch tests are not committed; the three fixtures above are the ones that distinguish old from new.

  • JVM: CometExpressionSuite HLL tests (5) on the default Spark 4.1 profile, with a libcomet built from this tree. I did not run the other Spark profiles locally; run-all-spark-profiles covers 4.0 and 4.2.
  • Not covered: Spark 4.0 ships DataSketches-Java 6.1.1, and I only generated fixtures with 6.2.0. #7396 includes doing both.

    Diff: 430 lines (+322 / -108) across 5 files Reviewer: sunchao Review duration: 619m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 430 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7402"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%