Repository navigation
Description
Problem
A deployment files and finds stored view states by ViewCoverage { definition_id, selection } (docs/design_docs/physical-planning-and-deployment.md §4, "The deployment matches a view to stored states by its coverage"; kll_tumbling_window_execution::a_store_keyed_by_definition_and_time_range_answers_the_tumbling_windows).
definition_id is logical (crates/types/src/plan/view_coverage.rs): the memo group's AggregateDefinition, expanded down to the Scans, JSON-serialized and FNV-1a-128 hashed. It includes the computation and summary_type, but not:
- θ, the sketch parameters (
PhysicalASAPDAGNode::parameters, e.g. KLLk); - the tumbling-window width: by design
SummaryMerge(TimeRange(W, Chain[w](X)))has the same coverage asSummaryAgg(TimeRange(W, X))(aggregate_coverage.rs, doc comment ofaggregate_coverage).
So two views, in one plan or in two plans, can have the same definition_id and selection while their stored states are not interchangeable (KLL k=200 vs k=400; 1-minute vs 5-minute windows). A store keyed by (definition_id, selection) returns the wrong state.
Proposal
Add a physical view id on each materialized view's node, computed the same way (canonical serialization, hashed), that changes exactly when two stored states are not interchangeable:
- in: the logical definition (computation,
summary_type, update, reduction), θ, the tumbling-window width; - out: refresh mode (
AtIngestion/OnFirstRead) andretention_ms, which change how a state is built or how long it is kept, not what it is; - out: the concrete data that went in (the selection's constraints and a window's exact start and end), which stays in
selectionand the request's time range.
Expose it on MaterializedView (e.g. MaterializedView::view_id()), and make it the key §4 tells deployments to use.
The logical definition_id
Outside tests and docs, definition_id's only consumer is the deployment's store key (materialized_view/views.rs requires view_coverage on every view for it). Once the physical id replaces it there, nothing uses it. Remove it from the plan (ViewCoverage, PhysicalASAPDAGNode::view_coverage's id), unless capability matching (#1430) needs a logical id to find a stored view that answers a query at a different θ; in that case keep it, documented as not a store key.
Acceptance
- Two views differing only in θ, or only in tumbling-window width, get different physical ids; two views differing only in refresh mode or retention get the same one.
- The physical id is the same across plans and processes for the same physical view (a durable store can key recovered states by it).
- §4 and the integration test key the store by the physical id.
Context
Needed by ASAPQuery's engine boundaries design for executing ASAPPlanner plans: ProjectASAP/ASAPQuery#935 (decisions 43–44, tabled T2).
Activity
zzylol commentedon Nov 19, 2026
Good point, I didn't realize there is no definition id with parameters.
But wait, we need to double-think here: view_coverage aims to provide the schema/semantics of the view, or computed intermediate states; the parameters like theta and window sizes should be additional fields to the view_coverage for the physical DAG. So, can we not change the logical coverage (because we have a full derivation algorithm for the coverage and schema of each node), but just add the parameters for the view store?
Another reason I suggest this is, we are treating parameters as properties in planning, and so does this for a physical plan, and data plane store -- meaning that when later we need capability matching based ad-hoc query planning in ASAPPlanner, we should check whether existing view properties satisfy the query accuracy requirement.
If you agree, would you mind changing the issue accordingly? Thanks
milindsrivastava1997 commentedon Nov 19, 2026
Revised proposal (supersedes the issue body), following @zzylol's comment.
Problem. A deployment files and finds stored view states by
ViewCoverage { definition_id, selection }(physical-planning-and-deployment.md§4).definition_idis logical: it hashes the view'sAggregateDefinition(computation,summary_type, update, reduction) down to theScans. It leaves out the sketch parameters θ (PhysicalASAPDAGNode::parameters) and the tumbling-window width, which by design is not part of the coverage. So two views can have equal coverage while their stored states can't be used for each other (KLLk=200vsk=400; 1-minute vs 5-minute windows). A store keyed by(definition_id, selection)would then return the wrong state.Proposal.
definition_id,selection) unchanged.MaterializedView, next to its coverage: θ and the tumbling-window width. That is exactly the set of fields that makes two stored states unusable for each other. Refresh mode andretention_msstay out, because they change how a state is built or kept, not what it is.(definition_id, physical properties, selection). Update §4 andkll_tumbling_window_execution's keyed-store test to match.Why properties instead of one physical hash. The planner already treats θ as a property of a plan. Capability matching (#1430) can then check whether a stored view's properties meet a query's accuracy requirement, which needs the logical id and the properties kept separate.
Acceptance.
definition_ids and different properties.zzylol commentedon Nov 20, 2026
Something is missing here. Due to that a
MaterializedViewis a sub-DAG, not just one node, the physical properties are per node (or memo group), the actual design should be a) the invariant is to keep the original node schema/coverage and selection, b) in the selected physical plan (which has a specific plan Id), each node has the property fields for theta, etc. And in the data plane interfaces, the MaterializedView interface shows the (plan id, node in selected physical plan).basically, the difference I'm proposing here is to add physical properties to the physical DAG (after it's being converted from physical memo group).
test(planner-cli): regenerate snapshots with each view's plan_id and …
docs: MaterializedView's fields and methods in the plan-file block (#…
test(types): failing tests for the view state key and plan id (#1429)
feat(types): name a materialized view by its view state key and plan …
fix(types): a TimeRange, TimeShift or TimeRangeCover view keeps its c…
test(planner-cli): regenerate snapshots with each view's plan_id and …
docs: MaterializedView's fields and methods in the plan-file block (#…
test(types): a finalized counter rate has the view coverage of the ra…
test(types): failing tests for the view state key and plan id (#1429)
feat(types): name a materialized view by its view state key and plan …
fix(types): a TimeRange, TimeShift or TimeRangeCover view keeps its c…
test(planner-cli): regenerate snapshots with each view's plan_id and …
docs: MaterializedView's fields and methods in the plan-file block (#…
test(types): a finalized counter rate has the view coverage of the ra…
refactor(types): view state key review fixes (#1429)
test(planner-cli): pin the view state key at main's plan; regenerate …
feat(types): name a materialized view by its view state key and plan …