From 196a86de987ef60a6bfb7d2c89c4fe44c533eef9 Mon Sep 17 00:00:00 2001 From: discord9 Date: Tue, 10 Nov 2026 15:53:22 +0800 Subject: [PATCH] feat(promql): compile absent_over_time on the native route (#10198) `absent_over_time([])` had no native kernel, so the statement declined to the existing planner; there a nameless selector has no metric name to look up, and the query failed instead of answering the label set Prometheus reports. Bind it to the whole-vector operation `absent` already uses, over a window read of the selector's range. The fold keeps the metric name: a presence fold that drops it would fold two metrics which differ only by name into one series and refuse the second value, while `absent` only asks whether the window held anything at all. Labels come from the same derivation `absent` uses, now also accepting a matrix selector. A statement holding a nameless selector that discovery expands into more than one metric table keeps declining: keeping the name would declare `__name__` without a bound metric name, and dropping it would merge the metrics. The typed empty input of a selector that matched no metric table is excluded from that decline, so a zero-match query plans natively and answers from it. The legacy planner is untouched. Signed-off-by: discord9 --- src/query/src/promql/native_compile.rs | 98 ++++++- src/query/src/promql/native_compile/tests.rs | 259 +++++++++++++++++++ src/query/src/promql/planner/native.rs | 39 +++ src/query/src/promql/planner/test.rs | 134 ++++++++++ tests-integration/src/tests/promql_test.rs | 177 +++++++++++++ 5 files changed, 698 insertions(+), 9 deletions(-) diff --git a/src/query/src/promql/native_compile.rs b/src/query/src/promql/native_compile.rs index 96a2bebe394..83176ea5bd6 100644 --- a/src/query/src/promql/native_compile.rs +++ b/src/query/src/promql/native_compile.rs @@ -31,6 +31,7 @@ //! () e.g. histogram_count(x) //! ([, ]*) e.g. sort_desc(x), sort_by_label(x, "job") //! absent() e.g. absent(x{job="a"}) +//! absent_over_time() e.g. absent_over_time(x{job="a"}[5m]) //! (+, ) e.g. histogram_quantile(0.9, rate(x[5m])) //!