pub fn plan(
pcx: Option<&PlanContext>,
catalog: &dyn SessionCatalog,
stmt: Statement<Aug>,
params: &Params,
resolved_ids: &ResolvedIds,
) -> Result<Plan, PlanError>
Expand description
Produces a Plan
from the purified statement stmt
.
Planning is a pure, synchronous function and so requires that the provided
stmt
does does not depend on any external state. Statements that rely on
external state must remove that state prior to calling this function via
crate::pure::purify_statement
or
crate::pure::purify_create_materialized_view_options
.
TODO: sinks do not currently obey this rule, which is a bug https://github.com/MaterializeInc/materialize/issues/20019
The returned plan is tied to the state of the provided catalog. If the state of the catalog changes after planning, the validity of the plan is not guaranteed.
Note that if you want to do something else asynchronously (e.g. validating
connections), these might want to take different code paths than
purify_statement
. Feel free to rationalize this by thinking of those
statements as not necessarily depending on external state.