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

Function get_object_store

datafusion-cli/src/object_storage.rs:516–579  ·  view source on GitHub ↗
(
    state: &SessionState,
    scheme: &str,
    url: &Url,
    table_options: &TableOptions,
    resolve_region: bool,
)

Source from the content-addressed store, hash-verified

514}
515
516pub(crate) async fn get_object_store(
517 state: &SessionState,
518 scheme: &str,
519 url: &Url,
520 table_options: &TableOptions,
521 resolve_region: bool,
522) -> Result<Arc<dyn ObjectStore>, DataFusionError> {
523 let store: Arc<dyn ObjectStore> = match scheme {
524 "s3" => {
525 let Some(options) = table_options.extensions.get::<AwsOptions>() else {
526 return exec_err!(
527 "Given table options incompatible with the 's3' scheme"
528 );
529 };
530 let builder =
531 get_s3_object_store_builder(url, options, resolve_region).await?;
532 Arc::new(builder.build()?)
533 }
534 "oss" => {
535 let Some(options) = table_options.extensions.get::<AwsOptions>() else {
536 return exec_err!(
537 "Given table options incompatible with the 'oss' scheme"
538 );
539 };
540 let builder = get_oss_object_store_builder(url, options)?;
541 Arc::new(builder.build()?)
542 }
543 "cos" => {
544 let Some(options) = table_options.extensions.get::<AwsOptions>() else {
545 return exec_err!(
546 "Given table options incompatible with the 'cos' scheme"
547 );
548 };
549 let builder = get_cos_object_store_builder(url, options)?;
550 Arc::new(builder.build()?)
551 }
552 "gs" | "gcs" => {
553 let Some(options) = table_options.extensions.get::<GcpOptions>() else {
554 return exec_err!(
555 "Given table options incompatible with the 'gs'/'gcs' scheme"
556 );
557 };
558 let builder = get_gcs_object_store_builder(url, options)?;
559 Arc::new(builder.build()?)
560 }
561 "http" | "https" => Arc::new(
562 HttpBuilder::new()
563 .with_client_options(ClientOptions::new().with_allow_http(true))
564 .with_url(url.origin().ascii_serialization())
565 .build()?,
566 ),
567 _ => {
568 // For other types, try to get from `object_store_registry`:
569 state
570 .runtime_env()
571 .object_store_registry
572 .get_store(url)
573 .map_err(|_| {

Callers 2

tableMethod · 0.85

Calls 8

newFunction · 0.85
buildMethod · 0.45
get_storeMethod · 0.45
runtime_envMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…