Skip to content

Revert "Revert "Implement PromQL range functions present_over_time, absent_over_time, quantile_over_time and predict_linear"" - #120352

Merged
vitlibar merged 3 commits into
masterfrom
revert-120336-revert-112842-promql/phase3-range-functions
Sep 17, 2026
Merged

vitlibar merged 3 commits into
masterfrom
revert-120336-revert-112842-promql/phase3-range-functions

Conversation

@vitlibar

@vitlibar vitlibar commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Reverts #120336


Workflow [PR]
Sync PR [sync-upstream/pr/120352]

…bsent_over_time, quantile_over_time and predict_linear""
@clickhouse-gh

clickhouse-gh Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9557d04]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

This revert-of-a-revert restores the PromQL range-function implementation and the translation-unit split that fixed the large-object build failure, but I do not think the current quantile_over_time path is mergeable yet. Besides a new out-of-bounds read in the phi array state capture, the PR still diverges from Prometheus on two legal quantile_over_time inputs that were previously raised and then resolved without code changes.

Findings

❌ Blockers

  • [src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesQuantileToGrid.cpp:53] AggregateFunctionTimeseriesQuantileToGridPhi::captureOrCheck treats offsets[row - 1] as if row 0 had a synthetic predecessor, but ColumnArray does not provide one. Any call whose first included row is row 0 and whose phi is an array reads before the offsets buffer, so the new feature's accept/reject path depends on unrelated memory instead of the query input.
  • [src/Storages/TimeSeries/PrometheusQueryToSQL/applyFunctionQuantileOverTime.cpp:160] [dismissed by author -- https://github.com/Revert "Revert "Implement PromQL range functions present_over_time, absent_over_time, quantile_over_time and predict_linear"" #120352#discussion_r4026477409] quantile_over_time is still advertised as implemented, but this branch throws NOT_IMPLEMENTED for legal PromQL like quantile_over_time(time(), m[5m] @ 1700000000). A fixed @ freezes only the range-vector window; the scalar phi is still evaluated per outer step, so rejecting the query is a compatibility gap, not a missing optimization.
  • [src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesQuantileToGrid.h:62] [dismissed by author -- https://github.com/Revert "Revert "Implement PromQL range functions present_over_time, absent_over_time, quantile_over_time and predict_linear"" #120352#discussion_r4026477420] The exact-rank shortcut still returns the sample directly instead of evaluating Prometheus's weighted form. That changes legal Inf inputs: quantile_over_time(0.5, vector(Inf)[2s:1s]) should yield NaN, but this code returns Inf.
Tests
  • ⚠️ The new coverage still does not protect the two quantile_over_time compatibility edges above: 05213_promql_quantile_over_time.sql asserts NOT_IMPLEMENTED for the fixed-@ plus varying-phi shape, and neither the stateless nor integration tests exercise Inf sample values. The smallest proof would be one positive PromQL test for quantile_over_time(time(), ... @ ...) and one quantile_over_time(..., vector(Inf)[...]) case.
Final Verdict
  • Status: ❌ Block
  • Minimum required actions:
  1. Fix the row-0 offset underflow in AggregateFunctionTimeseriesQuantileToGridPhi::captureOrCheck.
  2. Either implement fixed-@ quantile_over_time with a varying phi, or stop claiming/supporting that shape.
  3. Remove the exact-rank shortcut or otherwise make Inf inputs follow Prometheus's weighted semantics, and cover both quantile edge cases with regression tests.

LLVM Coverage Report

Measured on commit 9557d04.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.60% 80.60% +0.00%

Changed lines: Changed C/C++ lines covered: 2268/2382 (95.21%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 16, 2026
@vitlibar

Copy link
Copy Markdown
Member Author

@groeneai Add here a commit with your work on splitting the timeSeries*ToGrid registrations into per-family translation units from #120316

@vitlibar vitlibar added the do not test disable testing on pull request label Sep 16, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Sep 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

I cannot push to ClickHouse/ClickHouse (my account has triage, not write), so the commit is on my fork. It cherry-picks cleanly onto this PR's head 2fa78377:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/split-timeseries-registration-translation-units
git cherry-pick 60c63c1f406604607a79dd9fbcba87ac1dfa1fed

That is the single commit from #120316: the 20 timeSeries*ToGrid registrations move out of AggregateFunctionTimeseriesHelpers.cpp into 11 per-family translation units, the shared dispatch machinery moves to a new AggregateFunctionTimeseriesHelpers.h, and registerAggregateFunctionTimeseries() becomes 11 calls. 13 files, +2186/-1967, no CMake change (the directory is globbed).

I re-measured it on this PR's head in the release flavour with ThinLTO (-DENABLE_THINLTO=1, clang-22 per ci/defs/defs.py), which is the configuration where the gate fires:

tree Helpers.cpp.o largest object in the directory (limit 50,000,000 B) utils/check-large-objects.sh
2fa78377 56,842,832 B 56,842,832 B rc=1
2fa78377 + the commit 442,588 B 11,249,200 B (...LinearRegression.cpp.o) rc=0

clickhouse_aggregate_functions builds clean on your base, which is 88 master commits past the base #120316 was cut from. On #120316 I also checked that system.functions for timeSeries% is byte-identical across the split (48 rows, including the timeSeriesLastToGrid alias) and that the 22 timeSeries stateless tests pass; that content is unchanged here.

If you would rather not run git locally, say so and I will open a PR into revert-120336-revert-112842-promql/phase3-range-functions carrying just that commit.

@nikitamikhaylov

Copy link
Copy Markdown
Member

@groeneai please do.

…class files

Each class now registers its functions in its own cpp file, and
`registerAggregateFunctionTimeseries.cpp` calls all of them. The shared
helpers stay in `AggregateFunctionTimeseriesHelpers.cpp` with a new header.
@vitlibar vitlibar removed the do not test disable testing on pull request label Sep 16, 2026
@vitlibar

Copy link
Copy Markdown
Member Author

@groeneai please do.

Not necessary, I've already done it

@vitlibar
vitlibar marked this pull request as ready for review September 16, 2026 12:49
@vitlibar

Copy link
Copy Markdown
Member Author

@groeneai Analyze CI failures

@groeneai

Copy link
Copy Markdown
Collaborator

As of 14:30Z on a4165f74, exactly one job is red, and it is not caused by this PR.

Integration tests (amd_asan_ubsan, db disk, 7/8) (report, job log) died in the batch pre-pull step, before a single test ran; the only test row in the report is Post Hooks:

Pull of minio/mc:RELEASE.2025-04-16T18-13-26Z failed on attempt 3 (5s elapsed):
pull access denied for minio/mc, repository does not exist or may require 'docker login': denied
ERROR: Failed to pull the following image(s) after 3 attempt(s): minio/mc:RELEASE.2025-04-16T18-13-26Z

MinIO removed those images from Docker Hub. An anonymous manifest probe a minute ago: minio/mc and minio/minio both give 401 on registry-1.docker.io while library/alpine gives 200, and quay.io still serves the exact minio/mc tag. In this job the two minio/minio:RELEASE.2024-* tags did pull (7s each) and only minio/mc was denied, which fits the Hub proxy still holding the older tags but not this one.

Scope, from CIDB over the last 7 days (job-level rows whose context is Failed to pre-pull Docker images needed by the test batch): 334 job errors across 214 distinct trees and 165 PRs, 197 of them on this exact shard. On db disk, 7/8 alone the week is 268 green against 198 errored, a 42% error rate. Master is hit identically: 70 job errors across 20 master trees in the last 24 hours, for example master 2dc8de96f8bc.

A re-run will not clear it: of the trees that hit this on 7/8, ten got between 2 and 5 attempts and not one attempt ever went green.

The pins live in tests/integration/compose/docker_compose_minio.yml. #119999 repoints them at clickhouse/ mirrors and is waiting on one run of tests/integration/compose/mirror-images.sh by someone with clickhouse-org push rights, since the mirror repos do not exist yet. Until that happens the shard is red on every tree including master, so it carries no signal about this PR.

Everything else on a4165f74 is green (40 jobs). Still running: Build (arm_release), db disk shards 1-6/8 and 8/8, and Stateless tests (arm_binary, sequential).

On the re-landed feature itself nothing is red:

  • The gate that caused the revert is clear: Build (amd_release) is green, so the large-object check passes with the registration split in.
  • The four new stateless tests, counting the flaky-check repeats across five flavours: 05211_promql_present_over_time_absent_over_time 304 runs, 05213_promql_quantile_over_time 306, 05215_promql_predict_linear 308, 05214_timeseries_linear_regression_to_grid 309, all OK. The last one is the one that failed Fast test on Implement PromQL range functions present_over_time, absent_over_time, quantile_over_time and predict_linear #112842 on 09-15.
  • Integration tests (amd_asan_ubsan, flaky) ran the changed test_prometheus_protocols module, 33 tests, all OK. That module's regular home is db disk, 6/8, which is still running.

Two gaps worth knowing, since the automated review raised them and a green run reads as if it answered them. The fixed-@ case is asserted to throw (05213_promql_quantile_over_time.sql:52, -- { serverError NOT_IMPLEMENTED }), so that check stays green by construction whatever the behaviour should be. And no test anywhere in this run feeds an infinite sample value to quantile_over_time: every case varies the level instead, with finite samples, both in 05213 and in test_evaluation.py:1243-1274.

@clickhouse-gh

clickhouse-gh Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing commit 9557d04390f91772e142920d4da57e00a73500f0 with master failed: RuntimeError: CI logs cluster query failed: SELECT file, symbol, sumIf(size, side = 'pr….

See the job log for details.

@clickhouse-gh

clickhouse-gh Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master 57e97ff50

Metric Baseline Current Δ
Score 84.23% 96.47% +12.24%
Passed 454 520 +66
Failed 3 3 +0
Unsupported 82 16 -66

Uploaded compliance JSON for this PR commit

Baseline update

This run reports 96.47% vs master baseline 84.23% (57e97ff50). Merging to master will publish a new S3 object from the integration job that runs test_promql_compliance, which becomes the baseline for later PRs.

@vitlibar

Copy link
Copy Markdown
Member Author

@groeneai Investigate CI failure

@groeneai

Copy link
Copy Markdown
Collaborator

The only red on 9557d04390f9 is Build profile diff (arm_release): no test failed on this head, and nothing else on it is red, so none of it comes from the revert.

The job's read of per-symbol sizes from the CI logs cluster timed out, 8 attempts of 60s each ending in requests.exceptions.ReadTimeout inside LogCluster.select, after which compare_symbols raises RuntimeError: CI logs cluster query failed (job log).

That was cluster-wide rather than specific to this pull request: per CIDB, Build profile diff had zero successful runs repository-wide for the 14 hours from 2026-09-16 15:00Z to 2026-09-17 04:59Z (4 to 31 failures per hour), with successes resuming from 05:00Z. Three of the four attempts on this head sit inside that window (16 Sep 17:43Z, 19:58Z, 21:29Z); the fourth (today 08:14Z) hit a residual timeout in an hour where 8 of 18 runs passed, and the previous head a4165f74 passed this job at 14:36Z on 16 Sep, just before the outage began. A re-run of that single job should be green now.

Failing the check at all on a cluster read error is what I am fixing in #120121: when every attempt of the read is a 5xx or a timeout, the job reports SKIPPED with a comment saying the comparison did not run, instead of a failure that reads as a problem with the commit.

@vitlibar
vitlibar added this pull request to the merge queue Sep 17, 2026
Merged via the queue into master with commit 5c0772e Sep 17, 2026
692 of 697 checks passed
@vitlibar
vitlibar deleted the revert-120336-revert-112842-promql/phase3-range-functions branch September 17, 2026 10:31
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants