MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / enter_scope

Method enter_scope

src/sql/src/plan/lowering.rs:95–117  ·  view source on GitHub ↗

Updates references in the `ColumnMap` for use in a nested scope. The provided `arity` must specify the arity of the current scope.

(&self, arity: usize)

Source from the content-addressed store, hash-verified

93 /// Updates references in the `ColumnMap` for use in a nested scope. The
94 /// provided `arity` must specify the arity of the current scope.
95 fn enter_scope(&self, arity: usize) -> ColumnMap {
96 // From the perspective of the nested scope, all existing column
97 // references will be one level greater.
98 let existing = self
99 .inner
100 .clone()
101 .into_iter()
102 .update(|(col, _i)| col.level += 1);
103
104 // All columns in the current scope become explicit entries in the
105 // immediate parent scope.
106 let new = (0..arity).map(|i| {
107 (
108 ColumnRef {
109 level: 1,
110 column: i,
111 },
112 self.len() + i,
113 )
114 });
115
116 ColumnMap::new(existing.chain(new).collect())
117 }
118}
119
120/// Map with the CTEs currently in scope.

Callers 3

applied_toMethod · 0.80
branchFunction · 0.80
attempt_left_join_magicFunction · 0.80

Calls 6

updateMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
lenMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected