Skip to main content

TableScope

Struct TableScope 

Source
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

Source

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.

Source

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

Source

pub fn new() -> Self

Source

pub fn add(&mut self, table: ResolvedTable) -> Result<()>

Add a resolved table. Returns error if name conflicts.

Source

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.

Source

pub fn single_table(&self) -> Option<&ResolvedTable>

Get the single table in scope (for single-table queries).

Source

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.

Source

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.

Source

pub fn as_statement_output(self) -> Self

This scope marked as backing the SELECT that produces the statement’s result rows.

Source

pub fn is_statement_output(&self) -> bool

Whether the SELECT this scope backs produces the statement’s result rows.

Source

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.

Source

pub fn allows_cp_functions(&self) -> bool

Whether a sequence accessor resolves here despite rows being in scope.

Source

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.

Source

pub fn single(table: ResolvedTable) -> Result<Self>

A single-relation scope, for the DML planners that resolve one collection and build no FROM clause.

Source

pub fn check_name(&self, table_ref: Option<&str>, column: &str) -> Result<()>

Reject a column reference that names nothing in scope.

Source

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.
Source

pub fn with_column_naming(self, naming: ColumnNaming) -> Self

This scope with column references named for naming’s rows.

Source

pub fn column_naming(&self) -> ColumnNaming

How this scope’s column references name their fields.

Source

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.

Source

pub fn tables_in_order(&self) -> impl Iterator<Item = &ResolvedTable>

The resolved tables, in the order the FROM clause introduced them.

Source

pub fn table_by_ref(&self, ref_name: &str) -> Option<&ResolvedTable>

The relation registered under ref_name, alias or table name.

Source

pub fn declared_column( &self, table_ref: Option<&str>, column: &str, ) -> Option<&ColumnInfo>

The declared column a reference names, when the relation declares it.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableScope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TableScope

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more