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

Method enable_url_table

datafusion/core/src/execution/context/mod.rs:414–432  ·  view source on GitHub ↗

Enable querying local files as tables. This feature is security sensitive and should only be enabled for systems that wish to permit direct access to the file system from SQL. When enabled, this feature permits direct access to arbitrary files via SQL like ```sql SELECT * from 'my_file.parquet' ``` See [DynamicFileCatalog] for more details ``` # use datafusion::prelude::*; # use datafusion::{

(self)

Source from the content-addressed store, hash-verified

412 /// # }
413 /// ```
414 pub fn enable_url_table(self) -> Self {
415 let current_catalog_list = Arc::clone(self.state.read().catalog_list());
416 let factory = Arc::new(DynamicListTableFactory::new(SessionStore::new()));
417 let catalog_list = Arc::new(DynamicFileCatalog::new(
418 current_catalog_list,
419 Arc::clone(&factory) as Arc<dyn UrlTableFactory>,
420 ));
421
422 let session_id = self.session_id.clone();
423 let ctx: SessionContext = self
424 .into_state_builder()
425 .with_session_id(session_id)
426 .with_catalog_list(catalog_list)
427 .build()
428 .into();
429 // register new state with the factory
430 factory.session_store().with_state(ctx.state_weak_ref());
431 ctx
432 }
433
434 /// Convert the current `SessionContext` into a [`SessionStateBuilder`]
435 ///

Callers 6

thread_poolsFunction · 0.80
read_csvFunction · 0.80
query_aws_s3Function · 0.80
test_dynamic_file_queryFunction · 0.80
try_new_for_test_fileMethod · 0.80
main_innerFunction · 0.80

Calls 12

newFunction · 0.85
catalog_listMethod · 0.80
readMethod · 0.80
with_catalog_listMethod · 0.80
with_session_idMethod · 0.80
into_state_builderMethod · 0.80
with_stateMethod · 0.80
session_storeMethod · 0.80
state_weak_refMethod · 0.80
cloneMethod · 0.45
intoMethod · 0.45
buildMethod · 0.45

Tested by 2

test_dynamic_file_queryFunction · 0.64
try_new_for_test_fileMethod · 0.64