Repository navigation
fix(common-utils): merge DDSketch and GK quantile states with their accuracy - #3737
Draft
alex-fedotyev wants to merge 1 commit into
Draft
alex-fedotyev wants to merge 1 commit into
alex-fedotyev wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 13ef89a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
Contributor
E2E Test Results✅ All tests passed • 474 passed • 1 skipped • 1084s
Tests ran across 4 shards in parallel. |
…ccuracy A materialized view column built with quantileDD(accuracy, level) or quantileGK(accuracy, level) was merged as quantileDDMerge(level), which ClickHouse reads as an accuracy, so p95 came back as a different quantile with no error. GK merges failed the EXPLAIN check, so those views were skipped. The optimizer now reads the sketch's accuracy from the column type and keeps it on the rewritten select item, and the renderer emits quantileDDMerge(0.01, 0.95). The saved select schema doesn't change. Sketches whose state doesn't depend on the level (t-digest, reservoir, BFloat16, exact) render as before.
alex-fedotyev
force-pushed
the
alex/HDX-6120-trace-rollup-2-dd-merge-params
branch
from
November 24, 2026 02:07
465b9c5 to
13ef89a
Compare
This branch was successfully deployed
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.
Summary
A view column built with
quantileDDState(0.01, 0.5)orquantileGKState(100, 0.5)keeps the sketch's accuracy in its state, and the merge has to be given the same accuracy. The optimizer rewrote a p95 over such a column asquantileDDMerge(0.95)(col). ClickHouse accepts that, reads 0.95 as the accuracy, uses the default level, and returns an unrelated number without an error: 2,966 overnumbers(100000), where the p95 is 95,000. GK rejects the call (quantileGK requires accuracy parameter with integer type), so theEXPLAINcheck failed and GK views were never used. Alerts go through the same optimizer.The optimizer now reads the accuracy from the column's type and keeps it on the rewritten select item, and the renderer emits
quantileDDMerge(0.01, 0.95)(col), which returns 95,830 on the same data (within the sketch's 1%). Singular and plural states (quantilesDD(0.01, 0.9, 0.99)) both work. The accuracy only exists on the optimized config built at query time, so the saved chart schema and the external API don't change. Sketches whose only parameter is the level (t-digest, reservoir, BFloat16, exact) render as before, and no snapshot changes.No demo or built-in view stores DDSketch or GK states (the demo rollup uses t-digest), so the demo data shows no difference.
Stack
Second of three PRs in a GitHub stack (stack #3778). The header says this PR merges into the branch below it, but the stack's base is
main: merging a PR lands it and every PR below it onmain, one squashed commit each. Each diff is only its own change, and CI runs as if each PR targetsmain.The three changes don't depend on each other's code. They're groundwork for a default trace rollup, ordered smallest first.
How to reproduce
Starting point: any ClickHouse (
clickhouse localworks), and a checkout of this branch with Docker for the integration test.On
main:level_onlyis 2,966 andwith_accuracyis 95,830. The exact p95 is 95,000.mainand run the new integration test. The DDSketch and GK cases fail:On this branch:
make dev-int-common-utils FILE=materializedViewQuantileSketches: the test builds one-minute rollups withquantileDD,quantileGK,quantileTDigestandquantileBFloat16states over 100,000 spans, reads p95 and p99 through the optimizer at five-minute buckets, and all four come within their error bound ofquantileExacton the raw table.How to test on Vercel preview
N/A, non-UI change: no demo view stores DDSketch or GK states.
References