MCPcopy Create free account
hub / github.com/apache/datafusion / schema_for_ref

Method schema_for_ref

datafusion/core/src/execution/session_state.rs:343–367  ·  view source on GitHub ↗

Retrieve the [`SchemaProvider`] for a specific [`TableReference`], if it exists.

(
        &self,
        table_ref: impl Into<TableReference>,
    )

Source from the content-addressed store, hash-verified

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.

Callers 8

write_tableMethod · 0.80
statement_to_planMethod · 0.80
test_from_existingFunction · 0.80
register_tableMethod · 0.80
deregister_tableMethod · 0.80
table_existMethod · 0.80
table_providerMethod · 0.80
resolve_table_refMethod · 0.80

Calls 5

newFunction · 0.85
information_schemaMethod · 0.80
resolve_table_refMethod · 0.45
schemaMethod · 0.45
catalogMethod · 0.45

Tested by 1

test_from_existingFunction · 0.64