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

Function scan_for_relation

nodedb-sql/src/planner/join/plan.rs:173–200  ·  view source on GitHub ↗

Build a `SqlPlan::Scan` for a named-table TableFactor.

(rel: &ast::TableFactor, scope: &TableScope)

Source from the content-addressed store, hash-verified

171
172/// Build a `SqlPlan::Scan` for a named-table TableFactor.
173fn scan_for_relation(rel: &ast::TableFactor, scope: &TableScope) -> Result<SqlPlan> {
174 let (rel_name, rel_alias) =
175 crate::parser::normalize::table_name_from_factor(rel)?.ok_or_else(|| {
176 SqlError::Unsupported {
177 detail: "non-table JOIN target".into(),
178 }
179 })?;
180 let table = scope
181 .tables
182 .values()
183 .find(|t| t.name == rel_name || t.alias.as_deref() == Some(&rel_name))
184 .ok_or_else(|| SqlError::UnknownTable {
185 name: rel_name.clone(),
186 })?;
187 Ok(SqlPlan::Scan {
188 collection: table.name.clone(),
189 alias: rel_alias.or_else(|| table.alias.clone()),
190 engine: table.info.engine,
191 filters: Vec::new(),
192 projection: Vec::new(),
193 sort_keys: Vec::new(),
194 limit: None,
195 offset: 0,
196 distinct: false,
197 window_functions: Vec::new(),
198 temporal: crate::temporal::TemporalScope::default(),
199 })
200}

Callers 1

plan_join_from_selectFunction · 0.85

Calls 3

table_name_from_factorFunction · 0.85
findMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected