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

Method resolve

datafusion/catalog/src/async.rs:201–243  ·  view source on GitHub ↗

Creates a cached provider that can be used to execute a query containing given references This method will walk through the references and look them up once, creating a cache of table providers. This cache will be returned as a synchronous TableProvider that can be used to plan and execute a query containing the given references. This cache is intended to be short-lived for the execution of a s

(
        &self,
        references: &[TableReference],
        config: &SessionConfig,
        catalog_name: &str,
        schema_name: &str,
    )

Source from the content-addressed store, hash-verified

199 ///
200 /// See the [`AsyncSchemaProvider`] documentation for additional details
201 async fn resolve(
202 &self,
203 references: &[TableReference],
204 config: &SessionConfig,
205 catalog_name: &str,
206 schema_name: &str,
207 ) -> Result<Arc<dyn SchemaProvider>> {
208 let mut cached_tables = HashMap::<String, Option<Arc<dyn TableProvider>>>::new();
209
210 for reference in references {
211 let ref_catalog_name = reference
212 .catalog()
213 .unwrap_or(&config.options().catalog.default_catalog);
214
215 // Maybe this is a reference to some other catalog provided in another way
216 if ref_catalog_name != catalog_name {
217 continue;
218 }
219
220 let ref_schema_name = reference
221 .schema()
222 .unwrap_or(&config.options().catalog.default_schema);
223
224 if ref_schema_name != schema_name {
225 continue;
226 }
227
228 if !cached_tables.contains_key(reference.table()) {
229 let resolved_table = self.table(reference.table()).await?;
230 cached_tables.insert(reference.table().to_string(), resolved_table);
231 }
232 }
233
234 let cached_tables = cached_tables
235 .into_iter()
236 .filter_map(|(key, maybe_value)| maybe_value.map(|value| (key, value)))
237 .collect();
238
239 Ok(Arc::new(ResolvedSchemaProvider {
240 cached_tables,
241 owner_name: Some(catalog_name.to_string()),
242 }))
243 }
244}
245
246/// A trait for catalog providers that must resolve schemas asynchronously

Callers 2

checkFunction · 0.45
test_defaultsFunction · 0.45

Implementers 2

remote_catalog.rsdatafusion-examples/examples/data_io/r
async.rsdatafusion/catalog/src/async.rs

Calls 11

newFunction · 0.85
collectMethod · 0.80
catalogMethod · 0.45
optionsMethod · 0.45
schemaMethod · 0.45
contains_keyMethod · 0.45
tableMethod · 0.45
insertMethod · 0.45
to_stringMethod · 0.45
into_iterMethod · 0.45
mapMethod · 0.45

Tested by 1

test_defaultsFunction · 0.36