If `factor` is `ARRAY_*(name, ...)`, look up the array via the catalog and build a `ResolvedTable` whose columns mirror the array's dims + attrs. Returns `Ok(None)` for any non-array-TVF factor.
(
catalog: &dyn SqlCatalog,
factor: &sqlparser::ast::TableFactor,
)
| 218 | /// catalog and build a `ResolvedTable` whose columns mirror the array's |
| 219 | /// dims + attrs. Returns `Ok(None)` for any non-array-TVF factor. |
| 220 | fn resolve_array_tvf( |
| 221 | catalog: &dyn SqlCatalog, |
| 222 | factor: &sqlparser::ast::TableFactor, |
| 223 | ) -> Result<Option<ResolvedTable>> { |
| 224 | let (fn_name, args, alias) = match factor { |
| 225 | sqlparser::ast::TableFactor::Table { |
| 226 | name, |
| 227 | args: Some(args), |
| 228 | alias, |
| 229 | .. |
| 230 | } => ( |
| 231 | normalize_object_name_checked(name)?, |
| 232 | args, |
| 233 | alias.as_ref().map(|a| normalize_ident(&a.name)), |
| 234 | ), |
| 235 | _ => return Ok(None), |
| 236 | }; |
| 237 | if !matches!( |
| 238 | fn_name.as_str(), |
| 239 | "array_slice" | "array_project" | "array_agg" | "array_elementwise" |
| 240 | ) { |
| 241 | return Ok(None); |
| 242 | } |
| 243 | |
| 244 | // First positional arg is the array name as a string literal. |
| 245 | let first = args.args.first().ok_or_else(|| SqlError::Unsupported { |
| 246 | detail: format!("{fn_name}: missing array-name argument"), |
| 247 | })?; |
| 248 | let array_name = extract_string_literal_arg(first).ok_or_else(|| SqlError::Unsupported { |
| 249 | detail: format!("{fn_name}: array-name argument must be a string literal"), |
| 250 | })?; |
| 251 | let view = catalog |
| 252 | .lookup_array(&array_name) |
| 253 | .ok_or_else(|| SqlError::UnknownTable { |
| 254 | name: array_name.clone(), |
| 255 | })?; |
| 256 | |
| 257 | let info = CollectionInfo { |
| 258 | name: view.name.clone(), |
| 259 | engine: EngineType::Array, |
| 260 | columns: array_columns(&view), |
| 261 | primary_key: None, |
| 262 | has_auto_tier: false, |
| 263 | indexes: Vec::new(), |
| 264 | bitemporal: false, |
| 265 | primary: nodedb_types::PrimaryEngine::Document, |
| 266 | vector_primary: None, |
| 267 | }; |
| 268 | Ok(Some(ResolvedTable { |
| 269 | name: view.name, |
| 270 | alias, |
| 271 | info, |
| 272 | })) |
| 273 | } |
| 274 | |
| 275 | fn array_columns(view: &ArrayCatalogView) -> Vec<ColumnInfo> { |
| 276 | let mut cols = Vec::with_capacity(view.dims.len() + view.attrs.len()); |
no test coverage detected