diff --git a/crates/azure/Cargo.toml b/crates/azure/Cargo.toml index c9976fae9e..6ed096fa29 100644 --- a/crates/azure/Cargo.toml +++ b/crates/azure/Cargo.toml @@ -12,7 +12,9 @@ repository.workspace = true rust-version.workspace = true [dependencies] -deltalake-core = { version = "0.21.0", path = "../core" } +deltalake-core = { version = "0.21.0", path = "../core", features = [ + "datafusion", +] } lazy_static = "1" # workspace depenndecies @@ -20,7 +22,7 @@ async-trait = { workspace = true } bytes = { workspace = true } futures = { workspace = true } tracing = { workspace = true } -object_store = { workspace = true, features = ["azure"]} +object_store = { workspace = true, features = ["azure"] } thiserror = { workspace = true } tokio = { workspace = true } regex = { workspace = true } diff --git a/crates/azure/tests/integration.rs b/crates/azure/tests/integration.rs index 3ffaa00cc5..33d64f3967 100644 --- a/crates/azure/tests/integration.rs +++ b/crates/azure/tests/integration.rs @@ -1,6 +1,10 @@ #![cfg(feature = "integration_test")] +use std::assert_eq; +use std::collections::HashMap; + use bytes::Bytes; +use deltalake_core::data_catalog::storage::ListingSchemaProvider; use deltalake_core::DeltaTableBuilder; use deltalake_test::read::read_table_paths; use deltalake_test::{test_concurrent_writes, test_read_tables, IntegrationContext, TestResult}; @@ -89,3 +93,42 @@ async fn read_write_test_onelake(context: &IntegrationContext, path: &Path) -> T Ok(()) } + +#[test] +#[serial] +fn list_delta_tables_using_listing_provider_with_missing_account_name() -> TestResult { + let context = IntegrationContext::new(Box::new(MsftIntegration::default()))?; + // Removing the the envs set by the `IntegrationContext (az_cli::prepare_env())` to illustrate the issue if e.g. account_name is not set from custom `storage_options`, but still preserving the use of the `IntegrationContext` + std::env::remove_var("AZURE_STORAGE_USE_EMULATOR"); + std::env::remove_var("AZURE_STORAGE_ACCOUNT_NAME"); + std::env::remove_var("AZURE_STORAGE_TOKEN"); + std::env::remove_var("AZURE_STORAGE_ACCOUNT_KEY"); + + let storage_options = HashMap::::new(); + if let Err(read_error) = + ListingSchemaProvider::try_new(&context.root_uri(), Some(storage_options)) + { + assert_eq!(read_error.to_string(), "Failed to read delta log object: Generic MicrosoftAzure error: Account must be specified".to_string()); + }; + Ok(()) +} + +#[tokio::test] +#[serial] +async fn list_delta_tables_using_listing_provider_with_account_name() -> TestResult { + let context = IntegrationContext::new(Box::new(MsftIntegration::default()))?; + // Removing the the envs set by the `IntegrationContext (az_cli::prepare_env())` to illustrate the issue if e.g. account_name is not set from custom `storage_options`, but still preserving the use of the `IntegrationContext` + std::env::remove_var("AZURE_STORAGE_USE_EMULATOR"); + std::env::remove_var("AZURE_STORAGE_ACCOUNT_NAME"); + std::env::remove_var("AZURE_STORAGE_TOKEN"); + std::env::remove_var("AZURE_STORAGE_ACCOUNT_KEY"); + + let mut storage_options = HashMap::::new(); + storage_options.insert("account_name".to_string(), "test_account".to_string()); + let schema = ListingSchemaProvider::try_new(&context.root_uri(), Some(storage_options)); + assert!( + schema.is_ok(), + "Capable of reading the storage options. Fails if e.g. `account_name` is missing" + ); + Ok(()) +}