Repository navigation
Open
Labels
bugSomething isn't workingSomething isn't workingpromqlPromQL front-end lowering (L1→L2)PromQL front-end lowering (L1→L2)
Description
Example
This query plans but cannot be installed:
{"query_workload": {"language": "promql", "repeating_queries": [{
"query": "avg by (job) (label_replace(quantile_over_time(0.9, data[5m]), \"x\", \"$1\", \"instance\", \"(.*)\"))",
"demand": {"fixed_interval_at": {"interval": 60000, "evaluation_phase": 0}},
"requirements": {"accuracy": {"max_error": 0.05, "failure_probability": 0.3,
"accuracy_scope": "whole_result", "accuracy_metric": "relative"}},
"predictability": {"predictable": {"known_at": null}}}]},
"data_workload": {"arrival": {"ingesting": {"rows_per_second": 48.0}},
"sources": {"data": {"series_count": 12, "metric_type": "gauge", "sample_interval": 1000,
"column_signs": {"value": "non_negative"}}}}}The table shows results from planning and installing through the review harness, using the aws-fargate-us-east-1 cost inputs.
| Planner | Deployment | Plan (cost/s) | Install |
|---|---|---|---|
main (4a37273cb) |
raw data kept | exact: Scan → TimeRange → Aggregate[quantile] → PromqlRelabel → Aggregate[avg] (7.02e-12) |
QueryRunNotExecutable: invalid DAG: node 3: invalid DAG: value operation has no native implementation (node 3 is the PromqlRelabel) |
main |
no raw data | NoValidCandidate |
— |
| #1309 | raw data kept | DDSketch readout → PromqlRelabel → avg (6.35e-12) |
same error, at the PromqlRelabel node |
| #1309 | no raw data | DDSketch tumbling-window chain → PromqlRelabel → avg (4.56e-10) |
same error, at node 6, the PromqlRelabel |
Expected: the plan installs and returns the per-job mean of the 0.9-quantiles. The x label is a copy of instance, so the values are the same as without label_replace.
main already fails this way for the exact plan. #1309 gives relabels an error contract, so the sketch plans now reach the same error.
Why it happens
- The PromQL frontend lowers
label_replace(v, dst, replacement, src, regex)andlabel_join(v, dst, sep, src…)toNonASAPOp::PromqlRelabel { dst, value, child }. Herevalueis aFunctionCallnamedlabel_replaceorlabel_joinover the source label columns and literals (crates/frontend-promql/src/promql.rs,walk_label). - The executor's
bind_operationbindsProject,Filter,Sort,LimitandAggregateonly. Every other operator,PromqlRelabelincluded, falls through to_ => Err(invalid("value operation has no native implementation"))(physical_planner/mod.rs:1181). grep PromqlRelabel crates/executor/srcfinds no match.
Proposal
Bind PromqlRelabel as a per-row operator that copies every column and writes dst:
label_replace: ifregexfully matches thesrclabel (an absent label counts as""),dstbecomesreplacementwith$1,${name}and similar expanded. Otherwise the row is unchanged. An empty result removesdst.label_join:dstbecomes thesrclabels joined bysep. An empty result removesdst.- PromQL's rule applies: two output series with the same label set are an error.
- The executor's regex matcher (Executor: evaluate PromQL regex label matchers (=~, !~) #974) and its ASCII-class behaviour (PromQL regex classes \d, \w, \s, \b match Unicode; Prometheus matches ASCII only #981) apply to
regex.
Scope and acceptance
- In scope:
label_replaceandlabel_joinover an instant vector, at query time. At ingestion time the operator is only needed if the planner places a relabel there. - Acceptance: the example installs and executes on
main's exact plan and on fix(accuracy): relative error through negation, abs, set operators and relabels; readouts compose only through error-carrying inputs; exact accumulators take non-finite values and reject stale markers; finalize sign of counters #1309's DDSketch plans (raw data kept and not). The results match the exact reference within the 5% target. An executor unit test covers a capture-group replacement, a non-matching regex (row unchanged),label_joinwith an empty result (label removed), and a duplicate output label set (error).
Status and related work
- Found while verifying fix(accuracy): relative error through negation, abs, set operators and relabels; readouts compose only through error-carrying inputs; exact accumulators take non-finite values and reject stale markers; finalize sign of counters #1309 (Relative error through negation/abs/unless/label_replace; non-finite exact-sum input; finalize sign of rate accumulators #1307 L1). fix(accuracy): relative error through negation, abs, set operators and relabels; readouts compose only through error-carrying inputs; exact accumulators take non-finite values and reject stale markers; finalize sign of counters #1309 keeps the planner rule: the planner is not restricted by executor gaps.
- PromQL: label_replace/label_join unsupported #50 added the frontend lowering. Executor: evaluate PromQL regex label matchers (=~, !~) #974 added executor regex matchers.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpromqlPromQL front-end lowering (L1→L2)PromQL front-end lowering (L1→L2)
Activity