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

Method try_new

datafusion/core/src/datasource/dynamic_file.rs:56–89  ·  view source on GitHub ↗
(&self, url: &str)

Source from the content-addressed store, hash-verified

54#[async_trait]
55impl UrlTableFactory for DynamicListTableFactory {
56 async fn try_new(&self, url: &str) -> Result<Option<Arc<dyn TableProvider>>> {
57 let Ok(table_url) = ListingTableUrl::parse(url) else {
58 return Ok(None);
59 };
60
61 let state = &self
62 .session_store()
63 .get_session()
64 .upgrade()
65 .and_then(|session| {
66 session
67 .read()
68 .as_any()
69 .downcast_ref::<SessionState>()
70 .cloned()
71 })
72 .ok_or_else(|| plan_datafusion_err!("get current SessionStore error"))?;
73
74 match ListingTableConfig::new(table_url.clone())
75 .infer_options(state)
76 .await
77 {
78 Ok(cfg) => {
79 let cfg = cfg
80 .infer_partitions_from_path(state)
81 .await?
82 .infer_schema(state)
83 .await?;
84 ListingTable::try_new(cfg)
85 .map(|table| Some(Arc::new(table) as Arc<dyn TableProvider>))
86 }
87 Err(_) => Ok(None),
88 }
89 }
90}

Callers

nothing calls this directly

Calls 11

newFunction · 0.85
get_sessionMethod · 0.80
session_storeMethod · 0.80
readMethod · 0.80
infer_optionsMethod · 0.80
clonedMethod · 0.45
as_anyMethod · 0.45
cloneMethod · 0.45
infer_schemaMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected