Skip to content

feat(query): answer planned instant queries by running the plan's roots - #821

Draft
zzylol wants to merge 1 commit into
feat/precompute-enginefrom
feat/query-engine
Draft

zzylol wants to merge 1 commit into
feat/precompute-enginefrom
feat/query-engine

Conversation

@zzylol

@zzylol zzylol commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Stack 4/5. Base: #820. Next: #822.

Before this PR

Every query was forwarded to Prometheus.

After this PR

A planned instant query is answered by running its root of the DAG at time T:

  • Stored inputs: each reads the pane of its definition ending at T − offset.
  • Query-time raw inputs (TimeRange ← TimeShift* ← Scan): the data plane fetches (T − offset − range, T − offset] from Prometheus and filters it with the plan's Scan.
  • Responses: an answered query returns a Prometheus vector with x-asap-execution: plan. Any other query, including range queries, is forwarded with x-asap-execution: forwarded. A planned query that can't be answered gives its reason in x-asap-forward-reason: a missing pane, T off the pane grid, or an unsupported shape.

Limitations

  • Only instant queries are answered.
  • Stored panes need T on the pane grid.
  • Panes are kept in memory only.
  • Scalar roots aren't supported.

Testing

  • data_plane/tests/query.rs (3 tests).
  • data_plane/tests/answers.rs (2 tests) over HTTP against a stand-in Prometheus: Example 1 from raw samples, including the left-open range start, and Example 4b from panes built through Remote Write.

🤖 Generated with Claude Code

Each plan root is compiled once with two kinds of inputs: stored outputs,
bound at evaluation time T to their definition's pane ending at T - offset,
and query-time raw ranges (TimeRange <- TimeShift* <- Scan), bound to the
metric's samples in (T - offset - range, T - offset] fetched from
Prometheus and filtered by the plan's Scan. An instant query whose text is a
planned query is answered with a Prometheus vector and x-asap-execution:
plan. Unplanned queries are forwarded; planned ones that cannot be answered
(pane missing or off the pane grid, fetch or execution failure) are
forwarded with x-asap-forward-reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant