Repository navigation
Conversation
…mpatibility reasons hll_sketch_estimate now matches Spark bit-for-bit with datasketches 0.6.0, so it becomes Compatible. hll_sketch_agg, hll_union and hll_union_agg stay Incompatible with precise reasons: Comet writes LIST/SET mode sketches in the compact layout (apache#7548) and merged estimates can differ slightly. The error class mismatch is now a compatibility note (apache#7549). Closes apache#7396 Co-authored-by: Copilot <[email protected]> Copilot-Session: 64723000-41c4-41e1-9042-9efb440c7d08
tlfua
force-pushed
the
tlfua/feat/7396-hll-audit
branch
from
November 7, 2026 09:17
9fe68dd to
5124d53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #7396.
Rationale for this change
All four HLL expressions required
allowIncompatiblebecause "estimates may differ slightly". That reason was written against datasketches 0.3.0. After the upgrade to 0.6.0 (#7395), I compared Comet's code paths with the DataSketches-Java 6.2.0 logic Spark uses (experiment run, results in #7396 (comment) and #7396 (comment)):hll_sketch_estimatehll_sketch_agghll_unionallowDifferentLgConfigKand different lgK, estimate differs by up to about 1.6%hll_union_aggSo
hll_sketch_estimatecan run natively by default, while the other three still produce bytes that differ from Spark and stayIncompatible, now with a reason that says exactly what differs.Note: the experiment mirrors Spark's Java code and Comet's accumulator logic outside a real Spark/DataFusion plan. The tests in this PR verify end to end in CI.
What changes are included in this PR?
CometHllSketchEstimate: nowCompatible(noallowIncompatibleneeded on Spark 4.0+).CometHllSketchAgg,CometHllUnion,CometHllUnionAgg: stillIncompatible, with reasons replaced by the concrete differences above. Shared text lives in a newCometHllReasons.HLL_INVALID_INPUT_SKETCH_BUFFER/HLL_UNION_DIFFERENT_LG_K) moves fromgetIncompatibleReasonstogetCompatibleNotes. Both engines fail on the same inputs. The old reason also listed the wrong SQLSTATE forHLL_INVALID_INPUT_SKETCH_BUFFER(22546, not 22000).expressions.mdupdated, and audit entries added toexpression-audits/agg_funcs.mdandmisc_funcs.md.Follow-ups filed by this audit:
How are these changes tested?
expressions/misc/hll_sketch_estimate.sql(Spark 4.0+, Parquet dictionary on and off). Sketches are built by Spark for lgK 4/12/21 and 5 to 10000 distinct values, plus empty, NULL, andhll_union_aggresults. The estimate query must run natively and match Spark. An invalid-buffer case isquery ignore(...)and linked to [Bug] hll_* errors surface as Comet errors instead of HLL_INVALID_INPUT_SKETCH_BUFFER / HLL_UNION_DIFFERENT_LG_K #7549.Binarytype before any expression sees them (pinned bydictionary_columns_are_unwrapped_to_required_typesinnative/core/src/parquet/schema_adapter.rs, the same guarantee feat: run length on binary input natively #5874 relied on forlength), sospark_hll_sketch_estimatealways receives aBinaryArray. Theparquet.enable.dictionary=truerun of this test checks that end to end.CometExpressionSuite: new test checks thathll_sketch_estimateruns natively with no config and thathll_sketch_aggfalls back by default with the compact-layout reason. Existing HLL tests no longer setHllSketchEstimate.allowIncompatible.Local checks (no Maven build locally, CI runs the suites):
scalafmt --config scalafmt.conf --test(v3.6.1) on the changed Scala files: passed.npx prettier --checkon the changed Markdown files: passed.Requesting the
run-spark-4.0-tests/run-all-spark-profileslabels, since the serdes only apply on Spark 4.x.