Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion rust/lance-io/src/object_store/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ impl Default for ObjectStoreRegistry {
providers.insert("s3+ddb".into(), aws);
}
#[cfg(feature = "azure")]
providers.insert("az".into(), Arc::new(azure::AzureBlobStoreProvider));
{
let azure = Arc::new(azure::AzureBlobStoreProvider);
providers.insert("az".into(), azure.clone());
providers.insert("https".into(), azure);
}
#[cfg(feature = "gcp")]
providers.insert("gs".into(), Arc::new(gcp::GcsStoreProvider));
#[cfg(feature = "oss")]
Expand Down
25 changes: 25 additions & 0 deletions rust/lance-io/src/object_store/providers/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use snafu::location;

use object_store::{
azure::{AzureConfigKey, MicrosoftAzureBuilder},
path::Path,
RetryConfig,
};
use url::Url;
Expand Down Expand Up @@ -87,6 +88,20 @@ impl AzureBlobStoreProvider {

#[async_trait::async_trait]
impl ObjectStoreProvider for AzureBlobStoreProvider {
fn extract_path(&self, url: &Url) -> Result<Path> {
// Azure https paths in ObjectSore encode the container name as the first path segment.
// The actual object path starts from the second segment.
if url.scheme() == "https" {
url.path_segments()
.map(|s| Path::from_iter(s.skip(1)))
.ok_or_else(|| {
Error::invalid_input(format!("Invalid Azure URL: {url}"), location!())
})
} else {
Ok(Path::from(url.path()))
}
}

async fn new_store(&self, base_path: Url, params: &ObjectStoreParams) -> Result<ObjectStore> {
let block_size = params.block_size.unwrap_or(DEFAULT_CLOUD_BLOCK_SIZE);
let mut storage_options =
Expand Down Expand Up @@ -164,6 +179,16 @@ mod tests {
assert_eq!(path, expected_path);
}

#[test]
fn test_azure_store_https_path() {
let provider = AzureBlobStoreProvider;

let url = Url::parse("https://account.blob.core.windows.net/bucket/path/to/file").unwrap();
let path = provider.extract_path(&url).expect("Failed to extract path");
let expected_path = object_store::path::Path::from("path/to/file");
assert_eq!(path, expected_path);
}

#[tokio::test]
async fn test_use_opendal_flag() {
let provider = AzureBlobStoreProvider;
Expand Down
Loading