Repository navigation
Implement PromQL functions max_over_time() and min_over_time() - #112354
Conversation
|
Workflow [PR], commit [108d3ae] Summary: ✅
AI ReviewSummaryThis PR adds PromQL support for PR Metadata
Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictChanges requested. The equal-timestamp merge path in LLVM Coverage ReportMeasured on commit 108d3ae.
Changed lines: Changed C/C++ lines covered: 478/482 (99.17%) · Uncovered code |
08c61c0 to
8977fc9
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 209/213 (98.12%) · Uncovered code |
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/TimeSeries/AggregateFunctionTi… |
6.45 MiB | 8.43 MiB | +1.98 MiB (+30.80%) |
src/Examples/CMakeFiles/clickhouse-examples.dir/__/AggregateFunctions/examples/timeseries_to_grid_t… |
81.19 KiB | 132.89 KiB | +51.70 KiB (+63.68%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
14 translation units recompiled, 61 s compile time in total, 14 of them have a recent master baseline.
Median compile-time ratio to the baselines is ×1.05 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +12.1 s (+25%) in total before that adjustment.
| Translation unit | Master | PR | Δ vs median |
|---|---|---|---|
src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesHelpers.cpp |
26.2 s | 37.3 s | +9.7 s (+35%) |
Slowest changed entities of src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesHelpers.cpp:
- InstantiateFunction
DB::(anonymous namespace)::createAggregateFunctionTimeseries<(lambda at /ClickHouse/src/AggregateFu…: +0.9 s - InstantiateFunction
DB::(anonymous namespace)::createWithTimestampAndValueTypes<(lambda at /ClickHouse/src/AggregateFun…: +0.8 s - InstantiateFunction
DB::(anonymous namespace)::createAggregateFunctionTimeseries<(lambda at /ClickHouse/src/AggregateFu…: -0.9 s (-100%) - InstantiateFunction
DB::(anonymous namespace)::createWithTimestampAndValueTypes<(lambda at /ClickHouse/src/AggregateFun…: -0.8 s (-100%) - InstantiateFunction
DB::(anonymous namespace)::createAggregateFunctionTimeseries<(lambda at /ClickHouse/src/AggregateFu…: +0.6 s - InstantiateFunction
DB::(anonymous namespace)::createWithTimestampAndValueTypes<(lambda at /ClickHouse/src/AggregateFun…: +0.6 s - InstantiateFunction
DB::(anonymous namespace)::createAggregateFunctionTimeseries<(lambda at /ClickHouse/src/AggregateFu…: +0.6 s - InstantiateFunction
DB::(anonymous namespace)::createWithTimestampAndValueTypes<(lambda at /ClickHouse/src/AggregateFun…: +0.6 s
|
Update on the duplicate-timestamp thread: Duplicate-timestamp samples now collapse to the greatest value before the over-time extremum — Regressions in 04628 pin |
|
Dear @vitlibar, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…raits for the maximum and the minimum. Implement PromQL functions ts_of_max_over_time and ts_of_min_over_time.
8b5ffaa to
108d3ae
Compare
| /* drop_metric_name = */ true, | ||
| }}, | ||
|
|
||
| {"ts_of_max_over_time", |
There was a problem hiding this comment.
This hunk also exposes ts_of_max_over_time and ts_of_min_over_time, but the PR title, description, and changelog entry still only mention max_over_time and min_over_time. Please update the PR metadata so the contract, backport surface, and changelog cover all four user-visible PromQL functions added here.
|
I improved the solution in this PR, my changes:
|
PromQL Compliance ReportBaseline: S3 master
Uploaded compliance JSON for this PR commit Baseline updateThis run reports 84.23% vs master baseline 81.82% ( |
|
@valerypetrov @vitlibar — title/description suggestions: Description (currently
Ignore if intentional. |
Related: #57545
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
PromQL: implemented functions
max_over_time()andmin_over_time().Description
Implements
max_over_time(v range-vector)andmin_over_time(v range-vector), previously reported as not implemented.Unlike
sum/count, max/min are not invertible monoids, but they are commutative and associative (merge =max(a, b)/min(a, b)), so the new header (AggregateFunctionTimeseriesExtremumOverTime.h, templated on a boolis_max_) reusesAggregateFunctionTimeseriesSlidingSum's existing non-invertible sliding-window fallback (the same two-stacks/recompute machinery already shipped and tested viaderiv/predict_linear) — no new windowing logic was needed.Bucket == Summarydirectly, followingAggregateFunctionTimeseriesToGridSparse's (last_over_time's) simplest-case shape, since max/min don't depend on sample order. The comparison is NaN-aware (candidate > current || isnan(current)), matching Prometheus's own "a NaN currently held as the running extremum is unconditionally overwritten by the next sample" semantics.Registered
timeSeriesMaxToGrid/timeSeriesMinToGridinAggregateFunctionTimeseriesHelpers.cppand added the twoimpl_mapentries inapplyFunctionOverRange.cppwithdrop_metric_name = true, matchingrate/increase/delta's convention.Verified against Prometheus 3.5.0.
Testing: new SQL-level test (
04628_max_min_over_time_timeseries_functions.sql) including anAggregatingMergeTreeserialize/deserialize/merge round-trip, plus cases intests/integration/test_prometheus_protocols/test_evaluation.pycovering both functions over a series with decreases (so results differ meaningfully fromlast_over_time), including a more complex nested query. This flips 13 queries of the PromQL compliance suite from unsupported to passed.Workflow [PR]
Sync PR [sync-upstream/pr/112354]
Version info
26.9.1.1018(included in26.9and later)