Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions crates/iceberg/src/io/storage_azdls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ struct AzureStoragePath {

account_name: String,

/// Either `blob` or `dfs` for Blob Storage and ADLSv2 respectively.
storage_service: String,

/// The endpoint suffix, e.g., `core.windows.net` for the public cloud
/// endpoint.
endpoint_suffix: String,
Expand All @@ -249,10 +246,9 @@ impl AzureStoragePath {
/// This is possible because the path is fully qualified.
fn as_endpoint(&self) -> String {
format!(
"{}://{}.{}.{}",
"{}://{}.dfs.{}",
self.scheme.as_http_scheme(),
self.account_name,
self.storage_service,
self.endpoint_suffix
)
}
Expand All @@ -278,7 +274,6 @@ impl FromStr for AzureStoragePath {
scheme,
filesystem: filesystem.to_string(),
account_name: account_name.to_string(),
storage_service: storage_service.to_string(),
endpoint_suffix: endpoint_suffix.to_string(),
path: url.path().to_string(),
})
Expand Down Expand Up @@ -505,7 +500,7 @@ mod tests {
}

#[test]
fn test_parse_azure_storage_path() {
fn test_azure_storage_path_parse() {
let test_cases = vec![
(
"succeeds",
Expand All @@ -514,7 +509,6 @@ mod tests {
scheme: AzureStorageScheme::Abfss,
filesystem: "somefs".to_string(),
account_name: "myaccount".to_string(),
storage_service: "dfs".to_string(),
endpoint_suffix: "core.windows.net".to_string(),
path: "/path/to/file.parquet".to_string(),
}),
Expand Down Expand Up @@ -549,4 +543,48 @@ mod tests {
}
}
}

#[test]
fn test_azure_storage_path_endpoint() {
let test_cases = vec![
(
"abfss uses https",
AzureStoragePath {
scheme: AzureStorageScheme::Abfss,
filesystem: "myfs".to_string(),
account_name: "myaccount".to_string(),
endpoint_suffix: "core.windows.net".to_string(),
path: "/path/to/file.parquet".to_string(),
},
"https://myaccount.dfs.core.windows.net",
),
(
"abfs uses http",
AzureStoragePath {
scheme: AzureStorageScheme::Abfs,
filesystem: "myfs".to_string(),
account_name: "myaccount".to_string(),
endpoint_suffix: "core.windows.net".to_string(),
path: "/path/to/file.parquet".to_string(),
},
"http://myaccount.dfs.core.windows.net",
),
(
"wasbs uses https and dfs",
AzureStoragePath {
scheme: AzureStorageScheme::Abfss,
filesystem: "myfs".to_string(),
account_name: "myaccount".to_string(),
endpoint_suffix: "core.windows.net".to_string(),
path: "/path/to/file.parquet".to_string(),
},
"https://myaccount.dfs.core.windows.net",
),
];

for (name, path, expected) in test_cases {
let endpoint = path.as_endpoint();
assert_eq!(endpoint, expected, "Test case: {}", name);
}
}
}
Loading