Commit Graph
5758 Commits
Author SHA1 Message Date
Dennis Zhuang e57cd63014 fix(promql): sort classic buckets per point like Go and parse le like strconv
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:40:17 +08:00
Dennis Zhuang 781ccda356 fix(promql): order instant sorts with Go's sort algorithm
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:38:35 +08:00
Dennis Zhuang d6635400d4 chore: merge feat/narthex-map-label-time into feat/narthex-classic-histogram 2026-10-18 00:37:45 +08:00
Dennis Zhuang 857d8e0b6d docs(promql): list the regex dialect differences of label_replace
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:37:15 +08:00
Dennis Zhuang 1940a42449 chore: merge feat/narthex-window-eval into feat/narthex-map-label-time 2026-10-18 00:36:49 +08:00
Dennis Zhuang 96a7a2108f fix(promql): match each field of a vector on its own
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:36:27 +08:00
Dennis Zhuang 7b47b63e5c chore: merge feat/narthex-window-eval into feat/narthex-vector-match 2026-10-18 00:31:32 +08:00
Dennis Zhuang a4dda7262e chore: merge feat/narthex-window-eval into feat/narthex-select 2026-10-18 00:25:48 +08:00
Dennis Zhuang 581facd631 test(promql): pin name dropping for mad_over_time and ts_of_*
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:25:39 +08:00
Dennis Zhuang 26ee7145a9 chore: merge feat/narthex-window-eval-at into feat/narthex-new-eval 2026-10-18 00:24:52 +08:00
Dennis Zhuang d6f004aebb fix(promql): reject subquery grids longer than u64 and pin anchored predict_linear
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:24:26 +08:00
Dennis Zhuang 42662804eb chore: merge feat/narthex-window-eval-rate into feat/narthex-window-eval-at
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:24:05 +08:00
Dennis Zhuang a98c21e880 fix(promql): check smoothing factors at the first non-empty window
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:20:41 +08:00
Dennis Zhuang b300f02ebf chore: merge feat/narthex-window-eval into feat/narthex-window-eval-rate
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:20:03 +08:00
Dennis Zhuang f0086a354c fix(promql): keep no samples once the last window is evaluated
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-18 00:18:42 +08:00
Dennis Zhuang 088266b776 chore: merge feat/narthex-classic-histogram into feat/narthex-histogram-arith 2026-10-17 23:22:39 +08:00
Dennis Zhuang 09e3f67505 chore: merge feat/narthex-map-label-time into feat/narthex-classic-histogram 2026-10-17 23:22:28 +08:00
Dennis Zhuang 9611bb53a4 fix(promql): read replacement group names with Go's Unicode classes
Go reads a group name as Unicode letters, decimal digits and _, so in
$1² the name is 1; char::is_alphanumeric also takes ² and other number
characters.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:22:28 +08:00
Dennis Zhuang 329fed910b fix(promql): keep the first of equal classic bucket bounds like Prometheus
Prometheus compares bounds with < and >, so +0 and -0 are equal, keep
input order, and coalescing keeps the first; ordering -0 first returned
the other zero and flipped the sign of an infinite reciprocal.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:21:36 +08:00
Dennis Zhuang 104a8face2 chore: merge feat/narthex-window-eval-at into feat/narthex-new-eval
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval/tests.rs
2026-10-17 23:20:42 +08:00
discord9 0b412679c8 feat(query): add experimental_native_promql config option
Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
2026-10-17 23:20:32 +08:00
Dennis Zhuang 1b4fdb0314 chore: merge feat/narthex-window-eval-rate into feat/narthex-window-eval-at
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval/tests.rs
2026-10-17 23:19:55 +08:00
Dennis Zhuang 4caa7209a4 fix(promql): order signed zeros like Prometheus in quantile_over_time
Prometheus treats +0 and -0 as equal and sorts short windows by
insertion, keeping them in window order; sorting -0 before +0 picked
the other zero and flipped the sign of an infinite reciprocal.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:18:59 +08:00
Dennis Zhuang 09cb32a3e3 fix(promql): report 0 from ts_of_last_over_time for negative timestamps
Prometheus 3.15 takes the max of the last float timestamp and the
histogram one, which defaults to 0 without histograms.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:07:11 +08:00
Dennis Zhuang 5c9f734a02 perf(promql): write aggregated histograms from the first point with a result
The aggregation kept one owned histogram slot per point of the whole
input span before trimming, which for a sparse group allocated far more
than the result.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:06:23 +08:00
Dennis Zhuang cc19db9a94 chore: merge feat/narthex-classic-histogram into feat/narthex-histogram-arith 2026-10-17 23:04:33 +08:00
Dennis Zhuang 64ac8a8eb8 fix(promql): expand replacements like Go and merge label sets field by field
label_replace expands its template with Go's regexp.Expand rules, where
$01 or a reference of more than nine digits names a group. Series that
share a label set merge field by field, colliding only when one field
has two values at one point.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:04:22 +08:00
Dennis Zhuang 642cfc7c79 chore: merge feat/narthex-map-label-time into feat/narthex-classic-histogram 2026-10-17 23:04:22 +08:00
Dennis Zhuang 2ea2fb7f08 fix(promql): validate topk k and evaluate absent per field
topk and bottomk reject a NaN k and one out of int64, as Prometheus
does, instead of returning results. absent marks each field absent on
its own, as fields are evaluated independently.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 23:00:39 +08:00
Dennis Zhuang 0a494bdd56 chore: merge feat/narthex-classic-histogram into feat/narthex-histogram-arith
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/histogram_eval.rs
#	src/promql/src/histogram_eval/native.rs
2026-10-17 22:58:54 +08:00
Dennis Zhuang 423c1fee28 refactor(promql): use standard math for native histogram bounds and interpolation
Results only need to agree with Prometheus within the relative tolerance
promql-compat uses, so Go's bound table and the ports of math.Log2,
Exp2, Ldexp and Frexp go; the fixtures are compared within that
tolerance.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:58:03 +08:00
Dennis Zhuang 0db08505be refactor(promql): use the standard pow and atan2 in vector matching
Results only need to agree with Prometheus within the relative tolerance
promql-compat uses, so the ports of Go's math.Pow and math.Atan2 go; the
Go results stay as a fixture compared within that tolerance.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:54:32 +08:00
Dennis Zhuang c644ca3ac4 chore: merge feat/narthex-classic-histogram into feat/narthex-histogram-arith 2026-10-17 22:51:53 +08:00
Dennis Zhuang 5e82d88444 chore: merge feat/narthex-map-label-time into feat/narthex-classic-histogram 2026-10-17 22:51:42 +08:00
Dennis Zhuang 9b79dda801 chore: merge feat/narthex-window-eval into feat/narthex-map-label-time 2026-10-17 22:51:31 +08:00
Dennis Zhuang 591010f59e chore: merge feat/narthex-window-eval into feat/narthex-select 2026-10-17 22:51:21 +08:00
Dennis Zhuang bc8c172fdf chore: merge feat/narthex-window-eval into feat/narthex-vector-match 2026-10-17 22:51:10 +08:00
Dennis Zhuang a56faf76b9 chore: merge feat/narthex-window-eval-at into feat/narthex-new-eval
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval/tests.rs
2026-10-17 22:51:09 +08:00
Dennis Zhuang d7a5806dac chore: merge feat/narthex-window-eval-rate into feat/narthex-window-eval-at 2026-10-17 22:50:39 +08:00
Dennis Zhuang 1a32a74927 chore: merge feat/narthex-window-eval into feat/narthex-window-eval-rate
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval/tests.rs
2026-10-17 22:49:51 +08:00
Dennis Zhuang db555de0fc fix(promql): drop samples behind the next window while waiting for it
The evaluator stopped at a grid point whose window was not complete yet
before advancing past the samples that window cannot use, so a long gap
between grid points kept every sample pushed in the meantime.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:48:27 +08:00
Dennis Zhuang bba369cbcc chore: merge feat/narthex-classic-histogram into feat/narthex-histogram-arith
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/histogram_eval/tests.rs
2026-10-17 22:44:06 +08:00
Dennis Zhuang 53f5f69841 fix(promql): drop metadata labels from histogram_quantile and histogram_fraction
Prometheus drops __type__ and __unit__ with __name__ for these functions,
but only __name__ for the single-histogram functions.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:42:42 +08:00
Dennis Zhuang ee55e3bda7 fix(promql): drop metadata labels from date function results
Prometheus dateWrapper drops __type__ and __unit__ with __name__.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:41:31 +08:00
Dennis Zhuang 92015cf042 chore: merge feat/narthex-map-label-time into feat/narthex-classic-histogram 2026-10-17 22:41:31 +08:00
Dennis Zhuang 8c6ae77fa8 fix(promql): drop metadata labels from binary operator results
Arithmetic and bool comparisons drop __type__ and __unit__ with
__name__, as Prometheus does. __type__ stays part of the match group, so
results of different groups can now share a label set; that fails as
duplicate label sets after the operator, while two results within one
group still fail the group_x uniqueness check.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:40:17 +08:00
Dennis Zhuang 6ee0d745b0 fix(promql): keep the metric name in first_over_time results
Prometheus keeps the metric name for first_over_time as for
last_over_time.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:34:18 +08:00
Dennis Zhuang 4dc6bf690c chore: merge feat/narthex-window-eval-at into feat/narthex-new-eval
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval/tests.rs
2026-10-17 22:34:09 +08:00
Dennis Zhuang 98ff01f274 chore: merge feat/narthex-window-eval-rate into feat/narthex-window-eval-at
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

# Conflicts:
#	src/promql/src/range_eval.rs
2026-10-17 22:32:48 +08:00
Dennis Zhuang 2bf0bf4247 fix(promql): drop metadata labels from range function results
Prometheus drops __name__, __type__ and __unit__ from the result of every
range function except last_over_time and first_over_time; the evaluator
passed the metric through unchanged.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-10-17 22:30:39 +08:00