pub struct TableScope {
pub tables: HashMap<String, ResolvedTable>,
/* private fields */
}Expand description
Context built during FROM clause resolution.
Fields§
§tables: HashMap<String, ResolvedTable>Tables by reference name (alias or table name).
Implementations§
Source§impl TableScope
impl TableScope
Sourcepub fn bare_column_qualifier(&self, column: &str) -> Result<Option<String>>
pub fn bare_column_qualifier(&self, column: &str) -> Result<Option<String>>
The qualifier an unqualified column reference is rewritten to.
Some only over a join’s merged rows, for a column of one of this
scope’s own relations that the merged row keys by qualifier. The
reference is checked in every naming.
Sourcepub fn qualified_column_qualifier(&self, table_ref: &str) -> Option<String>
pub fn qualified_column_qualifier(&self, table_ref: &str) -> Option<String>
The qualifier a qualified column reference converts with.
A qualifier naming one of this scope’s own relations becomes that
relation’s row qualifier over a join’s merged rows, and is dropped
over a join aggregate’s output rows. Any other qualifier, and every
qualifier in AsWritten naming, is kept.
Source§impl TableScope
impl TableScope
pub fn new() -> Self
Sourcepub fn add(&mut self, table: ResolvedTable) -> Result<()>
pub fn add(&mut self, table: ResolvedTable) -> Result<()>
Add a resolved table. Returns error if name conflicts.
Sourcepub fn add_qualified_only(&mut self, table: ResolvedTable) -> Result<()>
pub fn add_qualified_only(&mut self, table: ResolvedTable) -> Result<()>
Add a relation that only a qualified reference reaches.
A bare column name skips it, so a name both this relation and a bare-resolvable one declare is not ambiguous.
Sourcepub fn single_table(&self) -> Option<&ResolvedTable>
pub fn single_table(&self) -> Option<&ResolvedTable>
Get the single table in scope (for single-table queries).
Sourcepub fn is_row_scope(&self) -> bool
pub fn is_row_scope(&self) -> bool
Whether an expression here is evaluated once per row of some relation.
A scope with no relation of its own and no enclosing query stands
behind a FROM-less SELECT, which produces exactly one row and
evaluates its projection at plan time.
Sourcepub fn nested_in(self, outer: TableScope) -> Self
pub fn nested_in(self, outer: TableScope) -> Self
A copy of this scope nested inside outer, for planning a correlated
subquery body. The body’s own clauses refuse a sequence accessor even
when the enclosing SELECT list allows one.
Sourcepub fn as_statement_output(self) -> Self
pub fn as_statement_output(self) -> Self
This scope marked as backing the SELECT that produces the statement’s result rows.
Sourcepub fn is_statement_output(&self) -> bool
pub fn is_statement_output(&self) -> bool
Whether the SELECT this scope backs produces the statement’s result rows.
Sourcepub fn allowing_cp_functions(self) -> Self
pub fn allowing_cp_functions(self) -> Self
This scope with sequence accessors allowed: the expression it resolves is a SELECT-list item the Control Plane evaluates per output row.
Sourcepub fn allows_cp_functions(&self) -> bool
pub fn allows_cp_functions(&self) -> bool
Whether a sequence accessor resolves here despite rows being in scope.
Sourcepub fn with_output_names(&self, names: impl IntoIterator<Item = String>) -> Self
pub fn with_output_names(&self, names: impl IntoIterator<Item = String>) -> Self
A copy of this scope widened with output column names.
An ORDER BY, GROUP BY, or HAVING identifier resolves against input columns first and output names second, so this only widens: a name that already resolves to a column keeps resolving to it.
Sourcepub fn single(table: ResolvedTable) -> Result<Self>
pub fn single(table: ResolvedTable) -> Result<Self>
A single-relation scope, for the DML planners that resolve one collection and build no FROM clause.
Sourcepub fn check_name(&self, table_ref: Option<&str>, column: &str) -> Result<()>
pub fn check_name(&self, table_ref: Option<&str>, column: &str) -> Result<()>
Reject a column reference that names nothing in scope.
Sourcepub fn resolve_bare(&self, column: &str) -> Result<BareColumn<'_>>
pub fn resolve_bare(&self, column: &str) -> Result<BareColumn<'_>>
Where an unqualified column reference resolves.
A SELECT output name wins. Otherwise the relations a bare name reaches are tried:
- One relation declares the column: it resolves there, even beside an open-schema relation.
- Two or more declare it: refused as ambiguous.
- None declares it and exactly one accepts any name (an open schema, an implicit column): it resolves there.
- None declares it and two or more accept any name: refused as ambiguous. Picking one would read NULL for a field the other holds.
- None accepts it: the enclosing query’s scope is tried, else the column is unknown.
Sourcepub fn with_column_naming(self, naming: ColumnNaming) -> Self
pub fn with_column_naming(self, naming: ColumnNaming) -> Self
This scope with column references named for naming’s rows.
Sourcepub fn column_naming(&self) -> ColumnNaming
pub fn column_naming(&self) -> ColumnNaming
How this scope’s column references name their fields.
Sourcepub fn check_using_column(
&self,
right_ref: Option<&str>,
column: &str,
) -> Result<()>
pub fn check_using_column( &self, right_ref: Option<&str>, column: &str, ) -> Result<()>
Reject a USING (column) key that right_ref’s relation or every
other relation lacks. Both sides of the join must carry it.
Sourcepub fn tables_in_order(&self) -> impl Iterator<Item = &ResolvedTable>
pub fn tables_in_order(&self) -> impl Iterator<Item = &ResolvedTable>
The resolved tables, in the order the FROM clause introduced them.
Sourcepub fn table_by_ref(&self, ref_name: &str) -> Option<&ResolvedTable>
pub fn table_by_ref(&self, ref_name: &str) -> Option<&ResolvedTable>
The relation registered under ref_name, alias or table name.
Sourcepub fn declared_column(
&self,
table_ref: Option<&str>,
column: &str,
) -> Option<&ColumnInfo>
pub fn declared_column( &self, table_ref: Option<&str>, column: &str, ) -> Option<&ColumnInfo>
The declared column a reference names, when the relation declares it.
Sourcepub fn resolve_from(
catalog: &dyn SqlCatalog,
functions: &FunctionRegistry,
temporal: TemporalScope,
from: &[TableWithJoins],
) -> Result<Self>
pub fn resolve_from( catalog: &dyn SqlCatalog, functions: &FunctionRegistry, temporal: TemporalScope, from: &[TableWithJoins], ) -> Result<Self>
Resolve tables from a FROM clause.
A derived-subquery factor is planned here so its relation carries the
search cells its plan produces; the planner context (functions,
temporal) is required for that and for no other arm.
Trait Implementations§
Source§impl Clone for TableScope
impl Clone for TableScope
Source§impl Debug for TableScope
impl Debug for TableScope
Auto Trait Implementations§
impl Freeze for TableScope
impl RefUnwindSafe for TableScope
impl Send for TableScope
impl Sync for TableScope
impl Unpin for TableScope
impl UnsafeUnpin for TableScope
impl UnwindSafe for TableScope
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.