Retrieve the [`SchemaProvider`] for a specific [`TableReference`], if it exists.
(
&self,
table_ref: impl Into<TableReference>,
)
| 341 | /// Retrieve the [`SchemaProvider`] for a specific [`TableReference`], if it |
| 342 | /// exists. |
| 343 | pub fn schema_for_ref( |
| 344 | &self, |
| 345 | table_ref: impl Into<TableReference>, |
| 346 | ) -> datafusion_common::Result<Arc<dyn SchemaProvider>> { |
| 347 | let resolved_ref = self.resolve_table_ref(table_ref); |
| 348 | if self.config.information_schema() && *resolved_ref.schema == *INFORMATION_SCHEMA |
| 349 | { |
| 350 | return Ok(Arc::new(InformationSchemaProvider::new(Arc::clone( |
| 351 | &self.catalog_list, |
| 352 | )))); |
| 353 | } |
| 354 | |
| 355 | self.catalog_list |
| 356 | .catalog(&resolved_ref.catalog) |
| 357 | .ok_or_else(|| { |
| 358 | plan_datafusion_err!( |
| 359 | "failed to resolve catalog: {}", |
| 360 | resolved_ref.catalog |
| 361 | ) |
| 362 | })? |
| 363 | .schema(&resolved_ref.schema) |
| 364 | .ok_or_else(|| { |
| 365 | plan_datafusion_err!("failed to resolve schema: {}", resolved_ref.schema) |
| 366 | }) |
| 367 | } |
| 368 | |
| 369 | /// Add `analyzer_rule` to the end of the list of |
| 370 | /// [`AnalyzerRule`]s used to rewrite queries. |