pub struct Scope {
pub scope_type: ScopeType,
pub sources: HashMap<String, Source>,
pub columns: Vec<ColumnRef>,
pub external_columns: Vec<ColumnRef>,
pub derived_table_scopes: Vec<Scope>,
pub subquery_scopes: Vec<Scope>,
pub union_scopes: Vec<Scope>,
pub cte_scopes: Vec<Scope>,
pub selected_sources: HashMap<String, Source>,
pub is_correlated: bool,
/* private fields */
}Expand description
Represents a single query scope and its relationships.
A scope is the context created by a query level (a SELECT, each branch of a UNION, each CTE definition, etc.). It tracks what tables are visible, what columns are referenced, and how nested scopes relate.
Fields§
§scope_type: ScopeTypeWhat kind of scope this is.
sources: HashMap<String, Source>Mapping of source name/alias → Source.
For tables this is alias.unwrap_or(name) → Source::Table(...).
For derived tables / CTEs it is alias → Source::Scope(...).
columns: Vec<ColumnRef>All column references found directly in this scope (not in child subquery scopes).
external_columns: Vec<ColumnRef>Columns that reference an outer scope (correlation).
derived_table_scopes: Vec<Scope>Child scopes created by derived tables (subqueries in FROM).
subquery_scopes: Vec<Scope>Child scopes created by scalar subqueries (in SELECT / WHERE / HAVING).
union_scopes: Vec<Scope>Child scopes for each branch of a UNION / INTERSECT / EXCEPT.
cte_scopes: Vec<Scope>Child scopes for CTE definitions.
selected_sources: HashMap<String, Source>Sources that are actually referenced by columns in SELECT (subset
of sources). Keyed the same way as sources.
Whether this scope contains correlated references to an outer scope.