Skip to content

Commit 5210ce1

Browse files
authored
Allow passing endpoint through the "adls.connection-string" (#23)
* allow passing endpoint through the adls.connection_string * Add storage endpoint option for azure * cargo fmt
1 parent 1bf6d27 commit 5210ce1

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed

crates/iceberg/src/io/storage_azdls.rs

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub const ADLS_CLIENT_SECRET: &str = "adls.client-secret";
5454
/// - default value: `https://login.microsoftonline.com`
5555
pub const ADLS_AUTHORITY_HOST: &str = "adls.authority-host";
5656

57+
/// The endpoint of the storage account.
58+
pub const ADLS_ENDPOINT: &str = "adls.endpoint";
59+
5760
/// Parses adls.* prefixed configuration properties.
5861
pub(crate) fn azdls_config_parse(mut properties: HashMap<String, String>) -> Result<AzdlsConfig> {
5962
let mut config = AzdlsConfig::default();
@@ -65,6 +68,10 @@ pub(crate) fn azdls_config_parse(mut properties: HashMap<String, String>) -> Res
6568
));
6669
}
6770

71+
if let Some(endpoint) = properties.remove(ADLS_ENDPOINT) {
72+
config.endpoint = Some(endpoint);
73+
}
74+
6875
if let Some(account_name) = properties.remove(ADLS_ACCOUNT_NAME) {
6976
config.account_name = Some(account_name);
7077
}
@@ -202,15 +209,20 @@ fn match_path_with_config(
202209
passed_http_scheme
203210
);
204211

205-
let ends_with_expected_suffix = configured_endpoint
206-
.trim_end_matches('/')
207-
.ends_with(&path.endpoint_suffix);
208-
ensure_data_valid!(
209-
ends_with_expected_suffix,
210-
"Storage::Azdls: Endpoint suffix {} used with configured endpoint {}.",
211-
path.endpoint_suffix,
212-
configured_endpoint,
213-
);
212+
// Skip endpoint suffix check for local endpoints (e.g., Azurite)
213+
let is_local =
214+
configured_endpoint.contains("127.0.0.1") || configured_endpoint.contains("localhost");
215+
if !is_local {
216+
let ends_with_expected_suffix = configured_endpoint
217+
.trim_end_matches('/')
218+
.ends_with(&path.endpoint_suffix);
219+
ensure_data_valid!(
220+
ends_with_expected_suffix,
221+
"Storage::Azdls: Endpoint suffix {} used with configured endpoint {}.",
222+
path.endpoint_suffix,
223+
configured_endpoint,
224+
);
225+
}
214226
}
215227

216228
Ok(())
@@ -363,6 +375,26 @@ mod tests {
363375
..Default::default()
364376
}),
365377
),
378+
(
379+
"endpoint pointing to azurite",
380+
HashMap::from([
381+
(
382+
super::ADLS_ENDPOINT.to_string(),
383+
"http://127.0.0.1:10000/devstoreaccount1".to_string(),
384+
),
385+
(
386+
super::ADLS_ACCOUNT_NAME.to_string(),
387+
"devstoreaccount1".to_string(),
388+
),
389+
(super::ADLS_ACCOUNT_KEY.to_string(), "secret".to_string()),
390+
]),
391+
Some(AzdlsConfig {
392+
endpoint: Some("http://127.0.0.1:10000/devstoreaccount1".to_string()),
393+
account_name: Some("devstoreaccount1".to_string()),
394+
account_key: Some("secret".to_string()),
395+
..Default::default()
396+
}),
397+
),
366398
(
367399
"account name and SAS token",
368400
HashMap::from([
@@ -489,6 +521,20 @@ mod tests {
489521
),
490522
Some(("myfs", "/path/to/file.parquet")),
491523
),
524+
(
525+
"azurite endpoint with explicit configuration",
526+
(
527+
"wasb://[email protected]/path/to/data.parquet",
528+
AzdlsConfig {
529+
account_name: Some("devstoreaccount1".to_string()),
530+
endpoint: Some("http://127.0.0.1:10000/devstoreaccount1".to_string()),
531+
account_key: Some("secret".to_string()),
532+
..Default::default()
533+
},
534+
AzureStorageScheme::Wasb,
535+
),
536+
Some(("testfs", "/path/to/data.parquet")),
537+
),
492538
];
493539

494540
for (name, input, expected) in test_cases {

0 commit comments

Comments
 (0)