(
state: &SessionState,
scheme: &str,
url: &Url,
table_options: &TableOptions,
resolve_region: bool,
)
| 514 | } |
| 515 | |
| 516 | pub(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(|_| { |
no test coverage detected
searching dependent graphs…