MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / resolve_table_factor

Method resolve_table_factor

nodedb-sql/src/resolver/columns.rs:168–214  ·  view source on GitHub ↗
(
        &mut self,
        catalog: &dyn SqlCatalog,
        factor: &sqlparser::ast::TableFactor,
    )

Source from the content-addressed store, hash-verified

166 }
167
168 fn resolve_table_factor(
169 &mut self,
170 catalog: &dyn SqlCatalog,
171 factor: &sqlparser::ast::TableFactor,
172 ) -> Result<()> {
173 // ARRAY_*(...) table-valued function: synthesize a ResolvedTable
174 // from the array's dim+attr schema so equi-join keys against the
175 // TVF's output rows resolve.
176 if let Some(resolved) = resolve_array_tvf(catalog, factor)? {
177 self.add(resolved)?;
178 return Ok(());
179 }
180 // LATERAL derived subquery: register the alias as a schemaless
181 // collection so qualified column references (`alias.col`) resolve
182 // without a catalog lookup. The actual inner plan is built separately.
183 if let sqlparser::ast::TableFactor::Derived {
184 lateral: true,
185 alias: Some(alias),
186 ..
187 } = factor
188 {
189 let alias_str = normalize_ident(&alias.name);
190 self.add(ResolvedTable {
191 name: alias_str.clone(),
192 alias: Some(alias_str.clone()),
193 info: CollectionInfo {
194 name: alias_str,
195 engine: EngineType::DocumentSchemaless,
196 columns: Vec::new(),
197 primary_key: None,
198 has_auto_tier: false,
199 indexes: Vec::new(),
200 bitemporal: false,
201 primary: nodedb_types::PrimaryEngine::Document,
202 vector_primary: None,
203 },
204 })?;
205 return Ok(());
206 }
207 if let Some((name, alias)) = table_name_from_factor(factor)? {
208 let info = catalog
209 .get_collection(DatabaseId::DEFAULT, &name)?
210 .ok_or_else(|| SqlError::UnknownTable { name: name.clone() })?;
211 self.add(ResolvedTable { name, alias, info })?;
212 }
213 Ok(())
214 }
215}
216
217/// If `factor` is `ARRAY_*(name, ...)`, look up the array via the

Callers 1

resolve_fromMethod · 0.80

Calls 6

resolve_array_tvfFunction · 0.85
normalize_identFunction · 0.85
table_name_from_factorFunction · 0.85
addMethod · 0.45
cloneMethod · 0.45
get_collectionMethod · 0.45

Tested by

no test coverage detected