Repository navigation
Implement PromQL functions stddev_over_time() and stdvar_over_time() - #112355
Conversation
|
Workflow [PR], commit [0a43944] Summary: ✅
AI ReviewSummaryThis PR adds Final Verdict✅ No new review findings. LLVM Coverage ReportMeasured on commit 0a43944.
Changed lines: Changed C/C++ lines covered: 228/230 (99.13%) · Uncovered code |
5b6356a to
6c51026
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 200/203 (98.52%) · Uncovered code |
be66b6a added a 0-argument call to IStorage::getInMemoryMetadataPtr() in StorageTimeSeriesSelector::readImpl(). The subsequent merge of upstream/master (01bea68) changed that virtual's signature to take (ContextPtr, bool) and return the lifetime-safe StorageMetadataHandle wrapper (whose operator-> is deleted on rvalues), breaking the build: error: too few arguments to function call, expected 2, have 0 error: overload resolution selected deleted operator '->' Pass context and bypass_metadata_cache=false, matching every other call site of this function in the codebase (e.g. AlterCommands.cpp, StorageBuffer.cpp), and bind the returned handle to a named variable before dereferencing it, since StorageMetadataHandle::operator->() const && is explicitly deleted. CI report: ClickHouse#112355 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…column f5ba06a added a physical `is_stale_marker UInt8` column to the TimeSeries "samples" inner table (normalizeTimeSeriesDefinition.cpp's normalizeInnerTableColumns()), so it now shows up as a 4th row in `SELECT name, type, compression_codec FROM system.columns` in all three scenarios this test covers (default codecs, after detach/attach, explicit columns). be66b6a already updated the sibling 04600_timeseries_column_validation.reference for the same reason but missed this one. CI report: ClickHouse#112355
Build profile diff (arm_release)Commit See the job log for details. |
|
|
||
| namespace DB | ||
| { | ||
|
|
There was a problem hiding this comment.
The implementation seems to be OK, but we can't merge the PR because it contains lots of unrelated changes. Please keep only changes related to adding these two functions stddev_over_time / stdvar_over_time in this PR and remove anything else from this PR
There was a problem hiding this comment.
Cleaned up these unrelated changes. Sorry for that. Should be ready for review.
d02686c to
f04b156
Compare
Add the aggregate functions `timeSeriesStddevToGrid` and
`timeSeriesStdvarToGrid` and wire them into `prometheusQuery` and
`prometheusQueryRange`. The state is a Welford/Chan `{count, mean, m2}`
accumulator, which avoids catastrophic cancellation on large-magnitude
series. Samples sharing a timestamp collapse to one value, as in the
other `timeSeries*ToGrid` functions. The result is always `Float64`.
Related: ClickHouse#57545
Co-Authored-By: Claude <[email protected]>
f04b156 to
1c0ace4
Compare
- Rename `AggregateFunctionTimeseriesVarianceOverTime` to `AggregateFunctionTimeseriesVariance`. - Tune the two-stacks thresholds to 4 and 10 with the `timeseries_to_grid_two_stack_vs_recompute` example, which now covers `timeSeriesStdvarToGrid`. - Remove the unreachable clamp of a negative variance, the redundant `DateTime64Supported` member, and reset `FORMAT_VERSION` to 1.
1c0ace4 to
0a43944
Compare
PromQL Compliance ReportBaseline: S3 master
Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream Uploaded compliance JSON for this PR commit Baseline updateThis run reports 98.70% vs master baseline 96.47% ( |
1b57158
Related: #57545
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
PromQL: implemented functions
stddev_over_time()andstdvar_over_time()(population standard deviation/variance).Description
Implements PromQL functions
stddev_over_time(v range-vector)andstdvar_over_time(v range-vector)using a numerically stable Welford/Chan accumulator, wires them into prometheusQuery/prometheusQueryRange, and adds SQL/integration coverage for duplicate timestamps, non-finite propagation, state merge/serialization, and large-magnitude regression cases.The accumulator keeps a running centered moment
{count, mean, m2}updated per sample with Welford's formula and merged pairwise with Chan et al.'s parallel merge, avoiding the catastrophic cancellation of the naivesum(x^2) - sum(x)^2/Nformula on large-magnitude counter series. Samples sharing a timestamp follow thetimeSeries*ToGridfamily contract and collapse to a single value per timestamp (timeseriesMaxValueForDuplicateTimestamp), both on ingestion and when partial states merge onAggregatingMergeTree.Registered the
timeSeriesStddevToGrid/timeSeriesStdvarToGridaggregate functions inAggregateFunctionTimeseriesHelpers.cppand added the twoimpl_mapentries inapplyFunctionOverRange.cppwithdrop_metric_name = true.Verified numerically against Prometheus 3.5.0 live responses, including cross-architecture (ARM64 vs x86_64) ULP tolerance handling in CI. This flips 12 queries of the PromQL compliance suite from unsupported to passed.
Testing: SQL-level test (
04628_variance_timeseries_functions.sql) covering empty/single/multi-sample windows andAggregatingMergeTreestate round-trips, plus integration cases intests/integration/test_prometheus_protocols/test_evaluation.pyfor instant/range evaluations and the correctness edges above.Workflow [PR]
Sync PR [sync-upstream/pr/112355]
Version info
26.10.1.615-master(included in26.10and later)