Repository navigation
Apache DataSketches Support for Cross-Service Sketch Interoperability & Analytics - #95045
MaheshGPai wants to merge 87 commits into
Conversation
|
Workflow [PR], commit [855237b] Summary: ❌
AI Review
|
|
Thanks! Also, use the template: https://github.com/ClickHouse/ClickHouse/blob/master/.github/PULL_REQUEST_TEMPLATE.md (you can paste it before or after the description) |
a81e079 to
10a07f2
Compare
|
Why not use combinators -Merge/-State for some custom aggregateFunction to implement behavior of serializedHLL/mergeSerializedHLL. |
The merge functions provided are for merging sketches produced external to CH. For example, an upstream service can perform first level aggregation of data and insert sketches as bytes (either raw or base64 encoded) |
I understand, but what is blocking us to interpret those sketches. We just had success, with use cases where people generate/converting and importing in ClickHouse TDigest/(some other agg functions) state and use native functions. So, it should be doable. |
I'm not familiar with that. If you can point me to an example, I can have a look. |
|
As simplest example, centroids from TDigest: So, basically i think there are several options exist:
|
The HIP estimate and the bytes of the sketch depend on the order of the updates and of the merges, so the planner must keep an `ORDER BY` below the function and below its `-State`, `-Merge` and `-If` forms. The property was copied from `uniq`, whose result does not depend on the order. Related: ClickHouse#95045 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: UnamedRus <[email protected]>
|
🕵 Continued on 2026-10-17: merged current @UnamedRus, thanks for #124667 (
If #124667 is chosen, the HLL functions here ( Related: #124667 |
Resolve the `contrib/datasketches-cpp` submodule conflict by taking master's `5.3.0` commit: merging `ClickHouse/5.3.0` into the PR's `ClickHouse/5.2.0-tdigest-iterator` yields a tree identical to `5.3.0`, which already contains the `tdigest` `const_iterator` and the `quantiles_sketch` deserialization fix used by this PR.
|
🕵 Continued on 2026-10-21: merged current
|
…infinite values Quantiles sketches accept `+inf` / `-inf`, and `writeText` printed them as bare `inf`, which is not valid JSON. Serialize values with `writeJSONNumber`, so non-finite values are quoted as in the `JSON` output formats and still round-trip through `JSONExtract`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=95045&sha=60237c99f2862bc82e097ae12871174a3852b7d8&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 ( |
|
This is the bug #126492 fixes. The stack here is Not caused by this PR: the same abort hit the Stress tests of 12 other PRs in the last 30 days. |
… without parameters `hll_union::update` ignores empty sketches, so merging only empty upstream sketches without explicit `lg_k` / `type` re-emitted an empty sketch with the default configuration. Track the configuration of empty inputs (smallest `lg_k`, widest type, so it is order-independent) and use it when the union result is empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Continued on 2026-11-05: pushed
|
…ging master Master stopped including `FormatSettings.h` (and with it `writeJSONNumber`) transitively from `WriteHelpers.h`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e input precision `HLLSketchData` could hold both an update sketch and a union at once: values inserted after a merge (e.g. by `arrayReduceInRanges`) went to the update sketch, while `size`/`serializedData` read only the union and `write`/`merge` only the update sketch, losing data. Now values are inserted directly into the union once it exists, and creating a union folds the update sketch in. `hll_union` adapts downward to the input `lg_k` only for dense inputs; sparse inputs are streamed into its own `MAX_LG_K` sketch. Track the smallest `lg_k` of non-empty inputs when `lg_k` is not explicit and downsample the result to it, also across partial-state serialization. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and `percentileFromTDigest` Comparisons with `NaN` are false, so `NaN` passed the range check and reached the sketch library, which casts the rank to an unsigned integer (undefined behavior). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and t-digests Imported sketches were merged into freshly created default sketches (`k = 128` for Quantiles, `k = 100` for t-digest), degrading upstream precision. Adopt the first imported sketch as is and keep the larger `k` when merging exact-mode Quantiles sketches or t-digests, so the result does not depend on the merge order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add pages with autogenerated markers for `serializedHLL`, `mergeSerializedHLL`, `serializedQuantiles`, `mergeSerializedQuantiles`, `serializedTDigest`, `mergeSerializedTDigest` and `uniqHLL`, so the docs generator picks up their `FunctionDocumentation`, together with slug map, redirect and navigation entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Conflict: `docs/_migration/slug-map.csv` was deleted on master (the whole `docs/_migration` folder was removed), while this branch added rows to it. Resolved by keeping the deletion.
…date` `readability-ambiguous-smartptr-reset-call` fails the `arm_tidy` builds, because `datasketches::hll_sketch` also has a `reset` method: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=95045&sha=4d8472c8c692c24365bbb5958a19cca618be908b&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 ClickHouse#95045 Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ters `serializedHLL`, `mergeSerializedHLL`, `mergeSerializedQuantiles` and `mergeSerializedTDigest` read these parameters through `FieldVisitorConvertToNumber<UInt64>`, which truncates fractional `Float64` and `Decimal` literals and wraps negative ones around. So `mergeSerializedHLL(0.5)` silently disabled base64 decoding and `serializedHLL(10.9)` used `lg_k = 10`. Now only a non-negative integer literal is accepted; anything else throws `ILLEGAL_TYPE_OF_ARGUMENT`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Continued on 2026-11-20: pushed
|
| const DataTypePtr & data_type = argument_types[0]; | ||
|
|
||
| WhichDataType which(*data_type); | ||
| if (which.isNumber()) |
There was a problem hiding this comment.
[Major] This validator accepts 128/256-bit integers as if this sketch could preserve them exactly, but the implementation immediately coerces every input to Float64 in add (column.getFloat64(row_num) here and in serializedTDigest). That makes distinct large integers collapse before they ever reach DataSketches — for example toUInt256(9007199254740992) and toUInt256(9007199254740993) become the same double.
That is a real contract problem for the serialized sketch surface: callers can hand you legal Int128/UInt128/Int256/UInt256 columns and get a sketch that no longer distinguishes adjacent values. Please either reject the wide integer types up front (matching the narrower quantileTDigest surface, which sticks to basic numerics) or make this lossy cast an explicit documented contract with focused regression coverage. The same issue exists in src/AggregateFunctions/AggregateFunctionSerializedTDigest.cpp:97 / src/AggregateFunctions/AggregateFunctionSerializedTDigest.cpp:57.
Closes: #95046
Add Apache DataSketches-compatible HLL, quantiles, and TDigest aggregate and scalar functions for importing, merging, and extracting metrics from externally produced sketches.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add Apache DataSketches-compatible HLL, quantiles, and TDigest sketch functions for cross-service sketch import, merging, and metric extraction.
Workflow [PR]
Sync PR [sync-upstream/pr/95045]