From c3e1c1ee136f7340b7268b74319a1322d9cfc5af Mon Sep 17 00:00:00 2001 From: Ritchie Vink Date: Wed, 18 Oct 2023 10:42:20 +0400 Subject: [PATCH] feat: don't require empty config for cloud scan_parquet (#11819) --- .../polars-io/src/cloud/object_store_setup.rs | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/crates/polars-io/src/cloud/object_store_setup.rs b/crates/polars-io/src/cloud/object_store_setup.rs index be7c4a28d822..5826c48f8bd1 100644 --- a/crates/polars-io/src/cloud/object_store_setup.rs +++ b/crates/polars-io/src/cloud/object_store_setup.rs @@ -22,13 +22,6 @@ fn err_missing_feature(feature: &str, scheme: &str) -> BuildResult { "feature '{}' must be enabled in order to use '{}' cloud urls", feature, scheme, ); } -#[cfg(any(feature = "azure", feature = "aws", feature = "gcp"))] -fn err_missing_configuration(feature: &str, scheme: &str) -> BuildResult { - polars_bail!( - ComputeError: - "configuration '{}' must be provided in order to use '{}' cloud urls", feature, scheme, - ); -} /// Build an [`ObjectStore`] based on the URL and passed in url. Return the cloud location and an implementation of the object store. pub async fn build_object_store(url: &str, options: Option<&CloudOptions>) -> BuildResult { @@ -47,6 +40,11 @@ pub async fn build_object_store(url: &str, options: Option<&CloudOptions>) -> Bu } let cloud_type = CloudType::from_str(url)?; + let options = key + .1 + .as_ref() + .map(Cow::Borrowed) + .unwrap_or_else(|| Cow::Owned(Default::default())); let store = match cloud_type { CloudType::File => { let local = LocalFileSystem::new(); @@ -55,11 +53,6 @@ pub async fn build_object_store(url: &str, options: Option<&CloudOptions>) -> Bu CloudType::Aws => { #[cfg(feature = "aws")] { - let options = key - .1 - .as_ref() - .map(Cow::Borrowed) - .unwrap_or_else(|| Cow::Owned(Default::default())); let store = options.build_aws(url).await?; Ok::<_, PolarsError>(Arc::new(store) as Arc) } @@ -68,12 +61,9 @@ pub async fn build_object_store(url: &str, options: Option<&CloudOptions>) -> Bu }, CloudType::Gcp => { #[cfg(feature = "gcp")] - match key.1.as_ref() { - Some(options) => { - let store = options.build_gcp(url)?; - Ok::<_, PolarsError>(Arc::new(store) as Arc) - }, - _ => return err_missing_configuration("gcp", &cloud_location.scheme), + { + let store = options.build_gcp(url)?; + Ok::<_, PolarsError>(Arc::new(store) as Arc) } #[cfg(not(feature = "gcp"))] return err_missing_feature("gcp", &cloud_location.scheme); @@ -81,12 +71,9 @@ pub async fn build_object_store(url: &str, options: Option<&CloudOptions>) -> Bu CloudType::Azure => { { #[cfg(feature = "azure")] - match key.1.as_ref() { - Some(options) => { - let store = options.build_azure(url)?; - Ok::<_, PolarsError>(Arc::new(store) as Arc) - }, - _ => return err_missing_configuration("azure", &cloud_location.scheme), + { + let store = options.build_azure(url)?; + Ok::<_, PolarsError>(Arc::new(store) as Arc) } } #[cfg(not(feature = "azure"))]