Repository navigation
Store promql_evaluation_time as a double, not a float - #120942
alexey-milovidov merged 8 commits into
Conversation
The setting is read as the instant a PromQL query is evaluated at, but it was declared FloatAuto, so it was held in a 32-bit float whose spacing at a present day Unix timestamp is 128 seconds. An explicit evaluation time was therefore moved by up to a minute before the query ran, which changes the sample an instant query returns and not merely the timestamp it reports: asking for 1789683929 evaluated at 1789683968. The same float is why SET and the query parameter disagreed about an integer. SET converts through a Field and demands the conversion be exact, so it refused a plain Unix timestamp with "is out of range of float type", while the query parameter and the command line parse from a string and rounded the same value without a word. Every integer below 2^53 converts exactly to a double, so both paths now accept the value and land on the same instant. DoubleAuto is the only change a setting needs here: SettingFieldDoubleAuto and its explicit instantiation already exist, and only the traits list was missing an entry for it. FloatAuto stays for the one probability setting that uses it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
|
Workflow [PR], commit [9ea4242] Summary: ✅
AI ReviewSummaryThis PR changes Findings
Final Verdict
LLVM Coverage ReportMeasured on commit 9ea4242.
Changed lines: Changed C/C++ lines covered: 8/8 (100.00%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
Neither contract this change fixes had a test. The tree exercised the table function's literal path and a cache test that passes an evaluation time without checking which instant it lands on, so a later change to the field type, to its string round-trip or to `SET` could bring back the minute-scale rounding or the refusal of an integer Unix timestamp without anything failing. The fixture is built around the arithmetic: two samples ten seconds apart, and an evaluation time of 1700000100, which a 32-bit float rounds to 1700000128, past the second one. The dialect returning 100 rather than 999 is therefore the assertion that the instant survived. `SET` and the command line are both driven, since they used to disagree about the same integer, and a fractional instant is checked because a float32 could not carry one at all. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
|
should be ready for review |
|
@groeneai , can you please check why the CI is failing here? |
|
Both reds come from
So there is nothing to fix on your side. Merging |
The precision test only writes external samples and tags. Let `TimeSeries` generate its unused metric-families target instead of defining an external table with the pre-version-6 `metric_family_name` column. This keeps the fixture compatible with both the PR base and current master without changing the evaluation-time assertions. Related: ClickHouse#120942 (comment) Related: ClickHouse#119226 CI: https://github.com/ClickHouse/ClickHouse/actions/runs/35799204924
Picks up ClickHouse#121820, which fixed the REPLICA_ALREADY_EXISTS race in test_active_node_owned_by_another_server that was the only diff-unrelated red. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@nikitamikhaylov , can you please recheck this one? I modified test which was failing on master. |
…on-time-precision Master moved the settings change history into the setting declarations, which conflicted with this branch's change of promql_evaluation_time from FloatAuto to DoubleAuto in Settings.cpp. Keep master's inline history rows and apply the branch's type and description on top. The default stays 'auto', so no new history row is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| \ | ||
| DECLARE_WITH_ALIAS(FloatAuto, promql_evaluation_time, Field("auto"), R"( | ||
| Sets the evaluation time to be used with promql dialect. 'auto' means the current time. | ||
| DECLARE_WITH_ALIAS(DoubleAuto, promql_evaluation_time, Field("auto"), R"( |
There was a problem hiding this comment.
DoubleAuto fixes the minute-scale Float32 rounding, but it still loses many fractional instants before parseTimeSeriesTimestamp sees them. At DateTime64(7+) scales a present-day value like 1700000100.0000001 cannot be represented exactly as Float64; by the time getFromFloat truncates float_value * scaleMultiplier, it becomes 1700000100.0000000. The timestamp parser already has exact String / Decimal carriers, but this setting declaration forces the value through a lossy binary float first.
The new regression test only uses 1700000100.5, which is exactly representable in binary and therefore misses this remaining wrong-answer case. If promql_evaluation_time is supposed to support fractional evaluation times at the table's native scale, please keep the original text / decimal form until parseTimeSeriesTimestamp parses it, or explicitly narrow the precision contract and test that narrower behavior.
PromQL Compliance ReportBaseline: S3 master
Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream Note: Prometheus compliance score is unchanged vs baseline. |
48f30f2
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed
promql_evaluation_timesilently rounding the requested instant, which could make an instant query return a different sample. The setting also now accepts an integer Unix timestamp over the native protocol, which it previously refused.Documentation entry for user-facing changes
The setting's description now states that the value is a Unix timestamp in seconds with an optional fraction. The reference page is regenerated from it.
promql_evaluation_timeis the instant a PromQL query is evaluated at, but it was declaredFloatAuto, so it was held in a 32-bit float. The spacing of afloatat a present-day Unix timestamp is 128 seconds, so an explicit evaluation time was moved by up to a minute before the query ran.That is a wrong answer, not a cosmetic one. With a series holding
100att-40and999att-10, asking fort-31:The same
floatis why the two ways of setting it disagreed.SETconverts through aFieldand demands the conversion be exact, so it refused a plain Unix timestamp:while the query parameter and the command-line flag parse from a string and rounded the same value without a word (
getSettingreturned1789683968, 38 seconds later than asked). Every integer below 2^53 converts exactly to adouble, so both paths now accept the value and land on the same instant.DoubleAutois all this needs:SettingFieldDoubleAutoand its explicit instantiation already exist inSettingsFields.h/SettingsFields.cppand were simply unreachable, because the traits list inSettings.hhad no entry for them.FloatAutostays foropentelemetry_start_keeper_trace_probability, a probability in[0, 1]where afloatis the right choice.A value already stored in a settings profile is text and is parsed on load, so nothing needs migrating, and settings cross the wire as decimal text rather than raw bytes, so a mixed-version cluster cannot break on this. Both are behaviour changes in the sense that a value that used to be rounded now is not — it moves toward what the operator wrote.
Found while testing #117170 against real scraped Prometheus data. It reproduces identically on a plain
TimeSeriestable, so it is not that PR's, and the PR's diff does not touch this declaration.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120942]
Version info
26.10.1.853-master(included in26.10and later)