Build a `SqlPlan::Scan` for a named-table TableFactor.
(rel: &ast::TableFactor, scope: &TableScope)
| 171 | |
| 172 | /// Build a `SqlPlan::Scan` for a named-table TableFactor. |
| 173 | fn 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 | } |
no test coverage detected