pub struct PlannerContext { /* private fields */ }Expand description
Struct to store the states used by the Planner. The Planner will leverage the states to resolve CTEs, Views, subqueries and PREPARE statements. The states include Common Table Expression (CTE) provided with WITH clause and Parameter Data Types provided with PREPARE statement and the query schema of the outer query plan.
§Cloning
Only the ctes are truly cloned when the PlannerContext is cloned.
This helps resolve scoping issues of CTEs.
By using cloning, a subquery can inherit CTEs from the outer query
and can also define its own private CTEs without affecting the outer query.
Implementations§
Source§impl PlannerContext
impl PlannerContext
Sourcepub fn with_prepare_param_data_types(
self,
prepare_param_data_types: Vec<FieldRef>,
) -> Self
pub fn with_prepare_param_data_types( self, prepare_param_data_types: Vec<FieldRef>, ) -> Self
Update the PlannerContext with provided prepare_param_data_types
Sourcepub fn outer_queries_schemas(&self) -> &[DFSchemaRef] ⓘ
pub fn outer_queries_schemas(&self) -> &[DFSchemaRef] ⓘ
Return the stack of outer relations’ schemas, the outer most relation are at the first entry
Sourcepub fn outer_schemas_iter(&self) -> impl Iterator<Item = &DFSchemaRef>
pub fn outer_schemas_iter(&self) -> impl Iterator<Item = &DFSchemaRef>
Return an iterator of the subquery relations’ schemas, innermost relation is returned first.
This order corresponds to the order of resolution when looking up column references in subqueries, which start from the innermost relation and then look up the outer relations one by one until a match is found or no more outer relation exist.
NOTE this is REVERSED order of Self::outer_queries_schemas
This is useful to resolve the column reference in the subquery by looking up the outer query schemas one by one.
Sourcepub fn append_outer_query_schema(&mut self, schema: DFSchemaRef)
pub fn append_outer_query_schema(&mut self, schema: DFSchemaRef)
Sets the outer query schema, returning the existing one, if any
Sourcepub fn latest_outer_query_schema(&self) -> Option<&DFSchemaRef>
pub fn latest_outer_query_schema(&self) -> Option<&DFSchemaRef>
The schema of the adjacent outer relation
Sourcepub fn pop_outer_query_schema(&mut self) -> Option<DFSchemaRef>
pub fn pop_outer_query_schema(&mut self) -> Option<DFSchemaRef>
Remove the schema of the adjacent outer relation
pub fn set_table_schema( &mut self, schema: Option<DFSchemaRef>, ) -> Option<DFSchemaRef>
pub fn table_schema(&self) -> Option<DFSchemaRef>
pub fn outer_from_schema(&self) -> Option<Arc<DFSchema>>
Sourcepub fn set_outer_from_schema(
&mut self,
schema: Option<DFSchemaRef>,
) -> Option<DFSchemaRef>
pub fn set_outer_from_schema( &mut self, schema: Option<DFSchemaRef>, ) -> Option<DFSchemaRef>
Sets the outer FROM schema, returning the existing one, if any
Sourcepub fn extend_outer_from_schema(&mut self, schema: &DFSchemaRef) -> Result<()>
pub fn extend_outer_from_schema(&mut self, schema: &DFSchemaRef) -> Result<()>
Extends the FROM schema, returning the existing one, if any
Sourcepub fn prepare_param_data_types(&self) -> &[FieldRef] ⓘ
pub fn prepare_param_data_types(&self) -> &[FieldRef] ⓘ
Return the types of parameters ($1, $2, etc) if known
Sourcepub fn contains_cte(&self, cte_name: &str) -> bool
pub fn contains_cte(&self, cte_name: &str) -> bool
Returns true if there is a Common Table Expression (CTE) / Subquery for the specified name
Sourcepub fn insert_cte(&mut self, cte_name: impl Into<String>, plan: LogicalPlan)
pub fn insert_cte(&mut self, cte_name: impl Into<String>, plan: LogicalPlan)
Inserts a LogicalPlan for the Common Table Expression (CTE) / Subquery for the specified name
Sourcepub fn get_cte(&self, cte_name: &str) -> Option<&LogicalPlan>
pub fn get_cte(&self, cte_name: &str) -> Option<&LogicalPlan>
Return a plan for the Common Table Expression (CTE) / Subquery for the specified name
Trait Implementations§
Source§impl Clone for PlannerContext
impl Clone for PlannerContext
Source§fn clone(&self) -> PlannerContext
fn clone(&self) -> PlannerContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PlannerContext
impl Debug for PlannerContext
Auto Trait Implementations§
impl Freeze for PlannerContext
impl !RefUnwindSafe for PlannerContext
impl Send for PlannerContext
impl Sync for PlannerContext
impl Unpin for PlannerContext
impl UnsafeUnpin for PlannerContext
impl !UnwindSafe for PlannerContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more