A raw series frame describes itself: its schema names the layout, the content,
the label mode and the ordering, so a consumer decodes it from the stream alone.
That makes the region's ordinary read path able to carry one - the handler returns
a record-batch stream, and Flight already sends a stream's schema with its
batches. What no region could do was produce one, because nothing asked for it.
A request now says which it wants, rows or frames. Nothing else travels: the
metric is the plan's own table scan, and the label mode, tags, fields and ordering
all come from the region's metadata, so a name, a tag list or an ordering did not
have to be added to the wire.
The read is served by the named binding a region already has - the same one the
PromQL planner uses - and a request that cannot be served fails naming the region,
the metric and the engine. It does not quietly answer with rows: a caller that
asked for frames built its plan around one shape, and different data under the
same question is worse than an error.
Two properties the ordinary path keeps:
- With no read kind the table provider builds exactly the `RegionScanExec` it
built before. That is the one guard, and it is what every request without an
explicit opt-in takes.
- A client cannot opt in by setting the extension itself. The region server
rewrites the key on every read from the decoded plan, so a header value is
overwritten before the provider sees it. Both halves have a test.
The named binding declines a scan that is not exactly one partition, so this read
is serialised behind one partition whatever the table's partitioning. That is a
limit of the binding, not of the frame, and the comment at the preparation site
says so along with why the alternative that would keep several partitions cannot
be called from this layer yet.
Signed-off-by: discord9 <discord9@163.com>
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
Stacked on #9868 (`feat/narthex-fused-wiring`, currently at
`990d932198ab0c5e41b724a54d990e5a8ffc8acb`). This change needs that PR's
unmerged `FusedSeries`/`SeriesScan`/in-process native route, so the base
is its branch; GitHub will retarget to `narthex` once #9868 merges.
## What's changed and what's your intention?
Enable the existing opt-in native PromQL route for literal vector/scalar
arithmetic such as `x * 100`, unary negation such as `-x`, and constant
scalar statements such as `1 + 2`. These public entries return ordinary
nonempty query RecordBatches with the same values and output schema as
the existing planner.
- Traverse unary and binary expression operands when locating the one
selector and its range requirements. Constant-only statements reuse the
existing constant evaluator and statement grid; unsupported shapes still
use the existing planner.
- Execute constant Scalar roots as one unlabelled evaluated chunk on the
full statement grid, with existing memory admission, output metrics and
error/cleanup paths. A no-input tree has genuinely zero logical/physical
children rather than a discarded placeholder scan.
- Keep each raw input partition attached to its own `FusedSeriesExec`
evaluator. This change adds neither an input-side Coalesce nor a
SeriesFrame exchange. Ordinary output collection continues to use
DataFusion.
- Cover scalar NaN/negative-zero/EOF/memory boundaries, child arity and
output schemas, independent lazy input progress, and the actual public
HTTP/query-handler route. The standalone single-region fixture persists
four disjoint input batches: for both broadcast and unary queries, all
four input/native partitions perform work and the complete result is
exactly 24 labelled timestamp/value rows. A four-stream barrier test
collected by DataFusion verifies concurrent progress; this is not a
CPU-overlap or speedup benchmark.
- Add a generated SQLness compatibility case for scalar arithmetic,
broadcast and unary results, rerun successfully without result changes.
Scope: constant scalar roots and literal broadcasts only.
`scalar(vector)` adaptation, dynamic per-grid scalar
arithmetic/broadcast, global Vector/Select and Complete Aggregate wiring
are separate work and are not enabled here. The experimental
configuration/request gates and current unsupported-shape fallback
remain in place. No persisted or remote wire format changes are
introduced; internal Fused constructor callers are migrated together.
Verification on this exact HEAD
(`d9eb9778f113dd9bd6125305a9ea447b4aa6ab1d`, restacked onto the current
dependency
`990d932198ab0c5e41b724a54d990e5a8ffc8acb`), exit 0:
```text
cargo fmt --all -- --check
git diff --check
cargo check --locked -p promql -p query --tests
cargo check --locked -p tests-integration --lib --test main
cargo nextest run --locked -p promql -p query --retries 0
1870 passed, 2 skipped
cargo nextest run --locked -p tests-integration --test main --retries 0 \
-E 'test(=integration_http_file_test::test_native_promql_route_plans_the_query) | test(=integration_http_file_test::test_prometheus_native_promql_route)'
2 passed, 770 filtered out (four real input partitions, exact 24 values)
cargo nextest run --locked -p tests-integration --lib --retries 0 -E 'test(native_promql_)'
4 passed, 251 filtered out (upstream VIEW/metric/ANALYZE compatibility)
cargo clippy --locked -p promql -p query --all-targets -- -D warnings
cargo clippy --locked -p tests-integration --lib --test main -- -D warnings
```
SQLness (generated, then rerun with an unchanged result):
```text
/mnt/nvme_rust/rust-targets-2/d-scalar-entry/debug/sqlness-runner bare \
--bins-dir .../debug --case-dir <isolated root> --test-filter '^standalone:scalar_entry$' --jobs 1
```
This SQLness case uses the default public compatibility route, not the
native request flag; it does not replace the native execution assertions
above. Full workspace `make test`/`make clippy`/udeps and external CI
have not been run for this change.
## PR Checklist
Please convert it to a draft if some of the following conditions are not
met.
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
- Rebased onto `narthex` at `bd6be2cf8f83b04280d3113467563ae81005e2f3`,
including merged #9868, #9937, #9914, #9870, #9871 and #9896. This PR no
longer depends on the old #9896 feature branch.
- Builds on the existing native Complete aggregate runtime from #9873.
#9936 can be restacked after this PR merges.
## What's changed and what's your intention?
Connect Complete aggregation to the current experimental native PromQL
execution path while preserving actual partition-local evaluation:
```text
SeriesScanExec N → FusedSeriesExec N → complete partial accumulator states N
→ CoalescePartitionsExec → FloatMerger → AggregateFinalizeExec 1 → ordinary RecordBatch
```
### Execution and current API adaptations
- Keep #9896's `FusedSeries.children`, physical children,
`BoundInput.source_index`, and existing ordinary multi-input execution.
An optional `partial_fold` changes only the output mode: ordinary
executions still emit query rows; aggregate producers fold evaluated
chunks into complete accumulator state and export it only after
successful input EOF. The aggregate path currently has one actual scan
child, with a separate evaluator for each of its N partitions; no gather
is inserted before evaluation.
- Split at the innermost supported Complete aggregate. The existing
`FloatMerger` combines full state, not finalized partition answers:
average retains count and compensated sum, and variance retains count,
mean and M2. The finalizer waits for all producer input to end
successfully before running the global suffix or returning rows. A late
source error fails the query rather than returning an incomplete
aggregate.
- Build the suffix as a separate `NativeTree`. Its `source_index = 0`
names its own evaluated input, not the original scan. Obtain the actual
input from `NativeExecutionState::input_ids(0)` and call
`NativeExecutor::push_evaluated(InputId, chunk)`; do not equate a source
index with a runtime input ID. No `NodePath` or flat executor is
restored.
- Use current `SeriesLabels` and the raw field layout from Native Input
output samples, without restoring a separate scan-schema mirror. Reuse
the existing row converter for final output. State and output
reservations are execution-local and released on errors and stream drop,
including when a physical plan is retained for another execution.
- Preserve `sum`, `avg`, `count`, `min`, `max`, `group`, `stddev` and
`stdvar`, `by` / `without`, maps and nested aggregate suffixes. Literal
scalar broadcasts work below the cut (`sum(8 * rate(...))`, `max(10 -
rate(...))`) and above it (`100 - avg(...)`, `sum(...) * 2`, `100 /
sum(...)`, `-sum(...)`), keeping subtraction and division operand order.
- Compose the current selector matcher/time-bound filters with aggregate
planning. Add `sum(rate(counter{job="a"}[5m]))` to the existing
standalone fixture; the independently expected answer is 9.
**The private state-row `RecordBatch` codec remains a temporary
bridge.** Producer, codec and finalizer retain the explanation that
future native final aggregation should consume series frames directly,
eliminating the intermediate state-row encoding, decoding and
reconstruction. This PR does not implement that replacement.
### Scope and compatibility
The supported target is standalone, one Region, multiple nonempty scan
partitions, with in-process region transport and the existing
engine/per-query native opt-ins. Ordinary Fused input traversal is not
redesigned. There is no cross-Region series merge, generic Exchange,
multi-input Aggregate Join, distributed Partial/Final architecture, new
public configuration, persisted format or wire format. No performance or
CPU-overlap improvement is claimed. Unsupported aggregate topologies
remain outside this PoC.
### Verification
All commands below passed on exact head
`9720e1bf88a776bd017b304152a055e1735d4ba1`, over the narthex base above,
using `RUST_MIN_STACK=8388608`, a dedicated external Cargo target, and
no test retries:
- `cargo fmt -p promql -p query -p tests-integration -- --check`
- `cargo check --locked -p query -p promql --all-targets`
- `cargo check --locked -p tests-integration --all-targets`
- `cargo nextest run --locked -p query -p promql --no-fail-fast
--retries 0` — **1967 passed, 2 skipped**.
- `cargo nextest run --locked -p tests-integration --lib --no-fail-fast
--retries 0 -E
'test(native_aggregate_complete_over_four_nonempty_mito_partitions) |
test(native_promql_)'` — **16 passed, 251 skipped**.
- `cargo clippy --locked -p query -p promql --all-targets --all-features
-- -D warnings`
- `cargo clippy --locked -p tests-integration --all-targets
--all-features -- -D warnings`
- `git diff --check bd6be2cf8f83b04280d3113467563ae81005e2f3..HEAD`
- `hawkeye format --dry-run` and `hawkeye check`
The standalone aggregate case checks typed physical-plan structure as
well as results: `SeriesScanExec` and partial Fused each retain four
partitions, with no intervening exchange; the finalizer consumes the
producer's state schema and answers one partition. For unfiltered
counter cases all four evaluators must report positive contributions,
totaling five and at most two per partition, forcing the three-member
group across partitions. Results are checked for labels, timestamps,
columns, values and multiplicity against independent expectations, in
addition to legacy execution.
The five nonzero counter rates are 1/3/5/2/4: total sum 15; per-job sums
9/6, means 3/3, counts 3/2 and standard deviations sqrt(8/3)/1. Scalar
cases include `sum(8 * rate(...)) = 120`, `max(10 - rate(...)) = 9`,
`100 - avg(...) = 97`, `100 / sum(...) = 100/15` and unary minus = -15.
The subtraction prefix distinguishes an incorrectly moved suffix (5) or
reversed operands (-5). The matcher selects three series, so only that
case does not require four nonempty partitions; all unfiltered
assertions remain intact.
Unit coverage includes all eight accumulator kinds, unequal producer
counts (one value versus two, so the merged mean is 6 rather than the
mean-of-means 5), nested/map/scalar suffixes, empty input, producer read
barriers, late errors, and reservation/drop boundaries. Local
full-workspace tests, an HTTP smoke run and native SQLness have not been
run; the SQLness runner does not carry the per-query native hint.
Final-head CI for `9720e1bf88a776bd017b304152a055e1735d4ba1` has
completed: [Rust
CI](https://github.com/GreptimeTeam/greptimedb/actions/runs/40201361500),
[Checks](https://github.com/GreptimeTeam/greptimedb/actions/runs/40201361419),
[Integration
CI](https://github.com/GreptimeTeam/greptimedb/actions/runs/40201361402)
all succeeded. The final check rollup contains 40 successful checks and
2 skipped checks, with no pending or failed checks. An earlier Semantic
Pull Request run was cancelled and superseded by a successful run; the
current Semantic PR title check passed. No workflow reruns were
requested.
## PR Checklist
Please convert it to a draft if some of the following conditions are not
met.
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
Uses the selector requirements and independent binary compilation
already merged in #9870 and #9871. This PR now targets `narthex`
directly.
## What's changed and what's your intention?
Run a compiled vector–vector expression from the real PromQL entry point
with **two independent scans**, including different matchers and time
bounds, instead of folding both operands onto one scan.
- `FusedSeries` keeps `Vec<LogicalPlan>` children in source-index order.
Each `BoundInput` names its child through `source_index`; its raw schema
remains in the compiled tree rather than being duplicated in the
binding. Logical identity includes source indices and ordered fields.
- The planner prepares each selector in its own context, preserves its
matcher filters, and adds its own compiler-derived scan bounds,
including range lower-edge semantics, `@` anchors and offsets. The two
scan children and source indices 0/1 remain distinct even for repeated
selectors.
- The physical adapter keeps the existing vector of `(physical plan,
label source, ordering)` tuples. Each child's frames are decoded and
labels materialized independently against that source's schema. A chunk
goes only to the runtime input IDs allocated for its source. Input ends
globally only after every source and partition has reached EOF;
errors/drop release queued inputs and evaluator reservations.
- Full raw tags remain available to bind scanners; one-to-one binary
output projects labels according to its matching rule, so `on(host)`
emits `host`, not an unrelated raw `kind` tag.
- A narrow same-table pair can use the existing in-process region-local
placement exception. Only that admitted root pair bypasses the unary
column-requirement rewriter; the general multi-input and wire-encoding
restrictions remain. This does not establish cross-region matching.
### Partitions and scope
A single physical input retains **Scan N → Fused N**. With two inputs,
**each scan retains N partitions**, while Fused reports one output
partition and consumes each source's partitions sequentially with a
separate decoder per partition. It does not pair left partition `i` with
right partition `i`, and the gathered stream is treated as `Contiguous`,
not globally `KeyThenTime`.
This is an experimental, opt-in **standalone, single-region PoC** for
ordinary Mito tables, millisecond timestamps, `Float64` fields, and
same-table one-to-one arithmetic pairs with default matching or nonempty
`on(...)`. It does not add cross-region routing, co-location, semantic
series merging, Exchange, global label sets, group matching, or a
general fallback-proof system. Metric-table pairs, comparisons, group
matching, empty `on()`, aggregates and subqueries are outside this pair
admission; existing single-selector admission is preserved.
The experimental internal Rust plan interface changes from a single
child to vectors; persisted schemas and wire formats do not change. No
release backport or official documentation-site change is required for
this default-off experimental extension.
### Verification
Completed local checks:
- `make fmt-check` and source-only `git diff --check`: passed. The
sqlness runner-owned `.result` EOF blank line is excluded from the
source whitespace check, not manually trimmed.
- `cargo check -p promql -p query --all-targets`: passed.
- `cargo nextest run -p promql -p query --retries 0 --no-fail-fast`:
**1,897 passed, 2 skipped**.
- `cargo clippy -p promql -p query --all-targets --all-features -- -D
warnings`: passed.
- `cargo check -p tests-integration --all-targets`: passed.
- `cargo nextest run -p tests-integration --lib --retries 0
--no-fail-fast -E 'test(native_promql)'`: **15 passed, 251 filtered
out**.
- `cargo clippy -p tests-integration --all-targets --all-features -- -D
warnings`: passed.
The direct integration regression reads 4,608 hosts from two distinct
`kind` matchers. It verifies the entire instant subtraction result
(`-915` per host) and independent anchored/offset rate result (`-3` per
host) against explicit numeric expectations and the legacy planner. Both
real scan children have four partitions and each produces rows on
multiple partitions; Fused has one output partition. Source indices,
host-only output labels, and each window's raw input-sample count are
asserted. Separate adapter tests cover distinct raw schemas, unequal
partition counts, later keys in earlier partitions, empty inputs,
ordering refusal and failure/drop cleanup. Single-child shared-input
tests retain Scan N → Fused N and once-per-partition scan execution.
- `cargo build -p cmd --bin greptime -p sqlness-runner`: passed; the SQL
run used that freshly built binary.
- `sqlness-runner bare -c "$CASE_DIR" -t fused_multi_standalone
--bins-dir "$CARGO_TARGET_DIR/debug" -j1` (`CASE_DIR` selects only the
checked-in standalone fixture): regenerated `.result` through the
runner, then reran successfully with an unchanged artifact hash. All
**13 TQL queries / 35 result rows** were checked independently for
values, timestamps and labels, including matcher subtraction `-45/-90`
and independently anchored rate subtraction `-9/-18`. This SQL case is a
public-semantics regression, not evidence of native routing or partition
activity; the direct integration test provides that evidence.
## PR Checklist
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [ ] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
Depends on the selector-binding PR #9870 (base branch
`feat/narthex-selector-bindings`); the
multi-scan execution wiring follows in #9896, based on this branch.
## What's changed and what's your intention?
Compile vector–vector arithmetic and comparison expressions into the
existing native `Binary`
runtime, with one independently bound input per selector occurrence.
- Replace the base's vector–vector refusal with the branch that compiles
both operands and binds the
matching: `on`/`ignoring`, `group_left`/`group_right`, `bool`, and the
`fill`/`fill_left`/
`fill_right` values, all through the existing matching types and
`binary_output_schema`.
- The base's scalar–vector path is untouched: `broadcast` and
`scalar_matching` still handle an
operation with one constant side, and a modifier written there is still
refused rather than
dropped.
- Set operators stay refused, as do vector–vector operations in the
tree-only `compile` entry, so a
caller cannot silently lose which scan feeds which selector;
`compile_selectors` is the entry for
multi-input expressions.
- Add ten real compiler-to-executor tests
(`src/query/tests/native_multi_selector.rs`) for arithmetic,
`on`/`ignoring`, grouping and fill, comparisons including output labels
and positions, distinct
fields/windows over the same metric, nested inputs, and a historical
range not clipped to the
statement start.
The tests supply fixture scans from the compiled requirements and feed
the returned executor paths.
Production Fused/scan-planner wiring and distributed placement are not
in this PR.
Validation on `f71f3bb4a94`:
- `cargo nextest run -p promql -p query`: 1814 passed, 2 skipped.
- `cargo nextest run -p query --test native_multi_selector`: 10 passed.
- `cargo nextest run -p query --lib promql::native_compile`: 97 passed.
- `cargo clippy -p query --all-targets --all-features -- -D warnings`:
passed.
## PR Checklist
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
Signed-off-by: discord9 <discord9@163.com>
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
First of three; vector–vector lowering (#9871) follows on this input
contract, and the multi-scan
execution wiring (#9896) follows that. Base is the fused wiring branch,
so the three form one
reviewable stack.
## What's changed and what's your intention?
Expose selector-specific scan requirements and executor input bindings
from the native PromQL
compiler without expanding its supported expression set.
- Add `compile_selectors`, whose callback receives metric, matchers,
resolved offset/anchor, actual
evaluation endpoints, and instant lookback or range-window duration, and
returns the selected raw
schema.
- Return each requirement and schema with its ordering and executor
`NodePath`, obtained through the
existing tree walker.
- Provide checked bounding scan intervals. Window and positive-lookback
lower edges are excluded;
zero-lookback instant selection includes the timestamp. The interval may
contain gaps not used by
individual evaluation windows.
- An anchored selector takes **both** edges from its anchor, not just
the upper one. Taking the lower
edge from the grid would scan from the statement's start, which is the
wrong side of the data for
an anchor before the statement and skips the selected sample for one
after it. Covered by
`an_anchored_instant_selector_scans_from_its_anchor`, which pins all
three cases: anchored inside
the statement, anchored before it, and a zero lookback.
- Preserve the existing `compile` API and selector/range/math behavior,
including the base's
scalar–vector broadcasting (`broadcast` / `scalar_matching`). A
vector–vector operation stays
refused here, naming the missing per-input identity.
Tests cover the callback requirement, schema identity in the actual
input node, nested input paths,
callback errors, offset/anchor bounds, anchored instant bounds, an
unaligned query end, lookback
boundaries, and overflow.
Validation on `d984231b6cb`:
- `cargo nextest run -p promql -p query`: 1800 passed, 2 skipped.
- `cargo nextest run -p query --lib promql::native_compile`: 93 passed.
- `cargo clippy -p query --all-targets --all-features -- -D warnings`:
passed.
No persisted or wire-format changes.
## PR Checklist
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
Signed-off-by: discord9 <discord9@163.com>
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
Split out of #9868, where it did not belong: the rename is not part of
the wiring.
## What's changed and what's your intention?
`datatypes::series::MetricName` did not hold a metric name. It held the
whole
PromQL-visible label set of one series — the `__name__` value plus its
ordinary
labels — with methods for label lookup, rewriting, keeping and removing
that
operate on the whole set. The name made every call site read as if a
series were
identified by its metric name, which it is not: two series share a
metric name
and differ in their other labels.
Rename the type to `SeriesLabels` so the name says what it holds, and
state in
its doc comment what it is *not*:
- not a canonical matching/grouping identity — matching drops `__name__`
and
compares the remaining labels canonically;
- not a storage identity — that is the read key / primary key.
The rename is mechanical: 58 files, +290/−279. No field, method, or
behaviour
changes. Identifiers that merely *begin* with the old name are untouched
—
`MetricNameLabel`, `MetricNameDiscovery`,
`PrometheusMetricNamesQueryPlan` keep
their names, since they refer to a metric name in the narrow sense and
are
correct as they are.
### Limitations
None. This is a rename; the type's representation and semantics are
unchanged.
## PR Checklist
Please convert it to a draft if some of the following conditions are not
met.
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
## What's changed and what's your intention?
**Summarize your change**
The native PromQL runtime addressed a node by the path that reached it.
Every
execution walked that path again to find the node's state, every metric
export
walked it to name a node, and the state itself lived in tables keyed by
that
path. This removes `NodePath` and the tables keyed by it, and replaces
them with
one recursive runtime tree: each node owns its children, its operator
state, its
metrics, and — once settled — nothing it no longer needs.
**How it works**
`NativeExecutionState` now holds a `RuntimeTree { root: RuntimeNode }`.
A
`RuntimeNode` carries its own `Box`ed children, its `Option` payload
(the
evaluator, the retained operands, the fold, the collected input), its
lifecycle
state and a shared `Arc<NodeMetrics>`, so there is no side table to look
a node
up in. Pulling, settling, flushing after a subtree closes, EOF, errors
and drop
all recurse through that tree.
An `InputId` is assigned only to the leaves that actually receive a
feed, by a
depth-first walk of the built tree. A scalar leaf takes no id, so no
node is
addressed by position and no flat registry stands in for the topology.
The feed
API is `push_raw(InputId, chunk)` / `push_evaluated(InputId, chunk)`;
there is no
`push_at` shim and no `input_count` nobody calls.
`EXPLAIN` and the per-node metrics are derived from the same tree: a
node's name
is produced only when a metrics set is exported, and the export walks
the tree at
that moment rather than consulting a stored path. `ANALYZE` reads the
same
runtime tree.
**Limitations**
- A node kind the runtime does not execute yet is still rejected when
the
execution is built, naming the kind. That set is unchanged by this PR.
- This is a runtime-layout change only: the compiled `NativeTree` stays
immutable
and carries no state, so it can still be used to build independent
executions.
- No persisted format, wire format or protocol changes.
**API or data compatibility**
No. Nothing here is persisted or sent over the wire; `InputId` is an
in-process
identity. Data and schema compatibility are unaffected.
## PR Checklist
- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels.
### Verification
- `cargo nextest run -p promql -p query` — **1829 passed, 2 skipped**
- `cargo clippy -p promql -p query --all-targets --all-features -- -D
warnings` — clean
- `cargo check -p promql --all-targets` and `-p query --all-targets` —
clean
- `hawkeye check` — no missing headers