feat: lower and compile PromQL histogram_quantile - #493
Merged
Merged
Conversation
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
fix/series-labels-duplicates
branch
from
September 30, 2026 18:27
17d1c12 to
ad45318
Compare
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
A without (le) HistogramQuantile aggregate compiles to a series operator that groups rows by every label except le, applies bucketQuantile, and drops le and __name__, rejecting equal result label sets. Conflicts with earlier stack changes resolved to the integration tree: - crates/asap-physical-operators/src/operators/mod.rs: 2bea2f6 Merge #493 classic histogram quantile coverage - series_labels.rs and tests/promql_fallback.rs: placement from 2bea2f6 without the later c39156e/15ab72b changes of this PR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
Conflicts with earlier stack changes resolved to the integration tree: - docs/develop_docs/physical-compile-coverage.md: 2bea2f6 Merge #493 classic histogram quantile coverage, without the paragraph that 6d895b7 in this PR adds later. The comparison section from #492 stays, the Remaining list drops the entries both PRs now cover, and the totals count both PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
feat/histogram-quantile
branch
from
September 30, 2026 18:27
6d895b7 to
fbeddda
Compare
zzylol
changed the base branch from
fix/series-labels-duplicates
to
fix/reject-promql-fill
September 30, 2026 18:28
zzylol
force-pushed
the
fix/reject-promql-fill
branch
from
September 30, 2026 20:24
feade00 to
6eb8a84
Compare
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
A without (le) HistogramQuantile aggregate compiles to a series operator that groups rows by every label except le, applies bucketQuantile, and drops le and __name__, rejecting equal result label sets. Conflicts with earlier stack changes resolved to the integration tree: - crates/asap-physical-operators/src/operators/mod.rs: 2bea2f6 Merge #493 classic histogram quantile coverage - series_labels.rs and tests/promql_fallback.rs: placement from 2bea2f6 without the later c39156e/15ab72b changes of this PR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
Conflicts with earlier stack changes resolved to the integration tree: - docs/develop_docs/physical-compile-coverage.md: 2bea2f6 Merge #493 classic histogram quantile coverage, without the paragraph that 6d895b7 in this PR adds later. The comparison section from #492 stays, the Remaining list drops the entries both PRs now cover, and the totals count both PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
feat/histogram-quantile
branch
from
September 30, 2026 20:24
fbeddda to
9b53ea7
Compare
zzylol
changed the base branch from
fix/reject-promql-fill
to
feat/kernel-codec-accessors
October 1, 2026 22:48
zzylol
force-pushed
the
feat/histogram-quantile
branch
from
October 1, 2026 22:48
9b53ea7 to
50c9d6d
Compare
zzylol
force-pushed
the
feat/kernel-codec-accessors
branch
from
October 1, 2026 23:06
b8440f7 to
a9db8d7
Compare
zzylol
force-pushed
the
feat/histogram-quantile
branch
from
October 1, 2026 23:14
50c9d6d to
ae5f517
Compare
This was referenced Oct 1, 2026
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.
Stacked on #494.
Rebuilt into the linear stack on main. New
integrate:commit(s) fold in integration-branch resolutions this PR needs on top of the earlier stack: "bind the histogram input layout in series_labels". Conflict resolutions are recorded in the messages of: "feat(physical): compile classic histogram_quantile in PromQL fallbacks"; "docs: record classic histogram_quantile coverage".Why
compilerejected PromQLhistogram_quantile(coverage row 10). The IR wasAggregate{by (), [HistogramQuantile{q}]}, so the compiler could not tell which series form one histogram, and the output lost its labels.What
AggIntent::HistogramQuantile { q, le: C }names the bucket-bound column. PromQL lowers the classic form toAggregate{Reduce(without([le])), [HistogramQuantile{q, le}]}. Thewithoutkeys seedleinto the selector schema even when no matcher names it. The SQLasap_histogram_quantilebridge keeps its single-histogramby ()and now namesle.withoutoutput schemas no longer keep a nested aggregate's renamed value (e.g.sum) as a label.SeriesHistogramQuantileoperator. It groups rows by every label exceptle(keeping__name__, as Prometheus does), appliesbucketQuantile, and dropsleand__name__. Result label sets that become equal are an error, as in Prometheus. It works on series-identity rows and plain label columns, so it coversrate(x_bucket[5m]),sum by (le, job) (…)and bare selectors.bucket_quantilenow matches Prometheus:almost.Equalfor the small-delta fix, so an infinite count is no longer merged into a finite one.levalues thatParseFloatrejects as out of range are skipped.KeepPreAsapsubtree for exact and approximate targets. No sketch candidates were added.Before this PR
histogram_quantile(0.5, sum by (le, job) (rate(x_bucket[5m])))→compileerror: "vector aggregate has no native lowering". Even if it had compiled, the IR described one quantile over all buckets with no labels.After this PR
With buckets
{1: 2, 2: 6, 4: 8, +Inf: 10}perjob=a, the query compiles through search and selection and returns{job="a"} 1.75. The hand-computed Prometheus result is1 + (2-1)·((5-2)/4). A per-seriesrate(x_bucket[5m])argument keeps{inst, job}.Known limits:
le(sum by (job) (…)) is rejected at lowering. Prometheus returns an empty vector for it.histogram_quantilesand aggregating over the result still don't compile. See the coverage doc.Validation
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace --no-fail-fastpass (1401 tests).asap-physical-operators/tests/promql_fallback.rscheck hand-computed results for:levalues, duplicate bounds and non-monotonic counts;ParseFloat-overflow and SQL-schema findings are fixed here.🤖 Generated with Claude Code