Repository navigation
fix(frontend): name every aggregate measure and validate names match measures - #1308
Merged
Merged
Conversation
…sures The PromQL counter-ranking TopK (`topk by (region) (4, increase(m[5m]))`), the canonicalize ranking promotion, and the SQL asap_rate/asap_increase aggregate were built with no output names, so the executor refused the installed plan with "aggregate output names differ from measures". Each now carries one empty name per measure (the intent-keyed default), as the other builders do. NonASAPOp::validate_inputs checks that an Aggregate has one output name per measure, so the planner refuses a mismatch at resolve and at memo insertion instead of the executor at install time. Test fixtures that built nameless aggregates are updated. Part of #1303.
… the mismatch error The Aggregate.output_names doc now says exactly one entry per measure, with an empty string meaning the default name (serde default kept for old JSON). The validation error gives both counts, and the unit test accepts an aggregate with no measures and no names. Part of #1303.
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
topk by (region) (4, increase(data_total[5m]))(and therateform) plans, then fails to install withQueryRunNotExecutable: invalid DAG: node 5: aggregate output names differ from measures. The PromQL frontend builds the counter-rankingTopKaggregate withoutput_names: [], but the executor needs one name per measure.Aggregatebuilder now gives one (empty, so default) name per measure: the PromQL counter-rankingTopK, thecanonicalizeranking promotion, and the SQLasap_rate/asap_increaseaggregate.NonASAPOp::validate_inputsnow refuses anAggregatewhose output names and measures differ. The planner checks this at resolve and at memo insertion, not the executor at install time.invalid DAG: node 5: invalid DAG: aggregate intent has no native implementation. The executor has no nativeTopKreduction yet. That half of [Bug] topk over rate/increase plans but fails installation: aggregate output names differ from measures #1303 waits for executor PR fix(executor): run each node by its plan Lifetime, so roots drain in any order #1300.Review guide
main(4a37273). Not stacked.crates/types/src/ir/operator/non_asap.rs(validate_inputs,Aggregatearm), then the three builders:crates/frontend-promql/src/promql.rs(Outer::TopKarm),crates/frontend-common/src/canonicalize.rs(ranking promotion),crates/frontend-sql/src/sql/mod.rs(asap_rate/asap_increase).crates/stage1-pass1-per-computation-candidates/src/candidates/mod.rs(single_measure_part). It used to give an empty list when the source had no name for that measure. It now always gives one name, so a split measure passes the new check.crates/types/src/ir/operator/asap.rschanges two schema-only temporary aggregates tovec![String::new()]. The rest are test fixtures that built nameless aggregates (output_names: vec![]→vec![String::new()]).topk_{k},rate, …), so no plan or snapshot changes.Behavior: before → after
The user writes this one-query workload (from #1303):
{"query_workload": {"language": "promql", "repeating_queries": [{ "query": "topk by (region) (4, increase(data_total[5m]))", "demand": {"fixed_interval_at": {"interval": 5000, "evaluation_phase": 0}}, "requirements": {"accuracy": {"max_error": 0.05, "failure_probability": 0.3, "accuracy_scope": "whole_result"}}, "predictability": {"predictable": {"known_at": null}}}]}, "data_workload": {"arrival": {"ingesting": {"rows_per_second": 200000.0}}, "sources": {"data_total": {"series_count": 10000, "metric_type": "counter", "sample_interval": 100}}}}plan_installablewithPlanningModels::builtin()Aggregate { Reduce([region]), [TopK { k: 4 }], output_names: [] }→Err(Installable(QueryRunNotExecutable { reason: "invalid DAG: node 5: invalid DAG: aggregate output names differ from measures" }))Aggregate { Reduce([region]), [TopK { k: 4 }], output_names: [""] }→Err(Installable(QueryRunNotExecutable { reason: "invalid DAG: node 5: invalid DAG: aggregate intent has no native implementation" }))The
rate(data_total[20m])form behaves the same way. Both results were checked with a temporaryplan_installabletest on this branch (not committed). This serves correctness: the planner now enforces the Aggregate contract the executor relies on. A future frontend gap now fails at lowering, and is no longer found only at install time.Interfaces
None. No public type, function or field changes.
NonASAPOp::validate_inputsispub(crate). It now also returns the existingSchemaDerivationError::InvalidScalarSignature("aggregate output names differ from measures")for a mismatchedAggregate. That is the same message the executor already used. No new error variant.Algorithm changes
None.
Decisions and open questions
validate_inputs), not in the executor. The rejected alternative from the issue was to make the executor treat an empty list as "default names". That leaves two encodings of one meaning, and the executor is not the place to catch frontend bugs. The check reuses the existingInvalidScalarSignaturevariant, like the othervalidate_inputschecks.Verification
Commands:
cargo test --workspace --exclude asap-executor --no-fail-fast,cargo test -p asap-executor,cargo fmt --all -- --check,cargo clippy -D warnings --all-targetson the changed crates.asap-types(lib +typestests)structure_contract::aggregate_output_names_match_measuresasap-frontend-commonlibasap-frontend-promql(promql+ corpus tests)promql)promql_lowering::topk_over_counter_rate_names_every_aggregate_measure; it fails on base 4a37273 withleft: 0, right: 1asap-frontend-sql,asap-frontend-metricsqlasap-stage0-memo, stage1/2/3 cratesasap-planner --test plannersummary_sharing::identical_ungrouped_queries_share_their_producersandruntime_install::check_compiles_reports_the_executors_error, which already fails on base with "aggregate intent has no native implementation" (counter topk, executor half)asap-integration-tests --test integrationpromql_to_post_asap::planner_heap_topk_reference_execution_matches_ground_truthasap-devtools --test devtoolstodo!("#1207 PR 9 …")inasap_plannerasap-executor-D warnings(types, frontend-common, frontend-promql, frontend-sql, stage0-memo, stage1-pass1)New tests:
topk_over_counter_rate_names_every_aggregate_measure: theincreaseandratecounter top-k queries lower toTopK { k: 4 }over the rate aggregate, and everyAggregatein the lowered DAG has one output name per measure.aggregate_output_names_match_measures:validate_inputsaccepts one empty or explicit name per measure, and rejects zero names or too many.Plan or snapshot changes: none. Output schemas are unchanged.
Follow-ups
TopKreduction in the executor'sAggregatecompile. It waits for executor PR fix(executor): run each node by its plan Lifetime, so roots drain in any order #1300. Until then the counter top-k query fails with "aggregate intent has no native implementation".random-mixed-seed-862-w02-q2-q7-mvpandrandom-mixed-seed-862-w01-q3-q8-mvp.Part of #1303.