-
Notifications
You must be signed in to change notification settings - Fork 540
feat(storage-azblob): Add Azure Blob Storage support #2908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jiaqizho
wants to merge
2
commits into
apache:main
Choose a base branch
from
jiaqizho:support-azblob
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| //! Azure Blob Storage configuration. | ||
| //! | ||
| //! This module provides configuration constants and types for Azure Blob Storage. | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
| use typed_builder::TypedBuilder; | ||
|
|
||
| use super::StorageConfig; | ||
| use crate::Result; | ||
|
|
||
| /// Azure Blob Storage endpoint URL. | ||
| pub const AZBLOB_ENDPOINT: &str = "azblob.endpoint"; | ||
| /// Azure Blob Storage account name. | ||
| pub const AZBLOB_ACCOUNT_NAME: &str = "azblob.account-name"; | ||
| /// Azure Blob Storage account key. | ||
| pub const AZBLOB_ACCOUNT_KEY: &str = "azblob.account-key"; | ||
| /// Azure Blob Storage shared access signature. | ||
| pub const AZBLOB_SAS_TOKEN: &str = "azblob.sas-token"; | ||
|
|
||
| /// Azure Blob Storage configuration. | ||
| /// | ||
| /// This struct contains all the configuration options for connecting to Azure Blob Storage. | ||
| /// Use the builder pattern via `AzblobConfig::builder()` to construct instances. | ||
| #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, TypedBuilder)] | ||
| pub struct AzblobConfig { | ||
| /// Endpoint URL. | ||
| #[builder(default, setter(strip_option, into))] | ||
| pub endpoint: Option<String>, | ||
| /// Account name. | ||
| #[builder(default, setter(strip_option, into))] | ||
| pub account_name: Option<String>, | ||
| /// Account key. | ||
| #[builder(default, setter(strip_option, into))] | ||
| pub account_key: Option<String>, | ||
| /// SAS token. | ||
| #[builder(default, setter(strip_option, into))] | ||
| pub sas_token: Option<String>, | ||
| } | ||
|
|
||
| impl TryFrom<&StorageConfig> for AzblobConfig { | ||
| type Error = crate::Error; | ||
|
|
||
| fn try_from(config: &StorageConfig) -> Result<Self> { | ||
| let props = config.props(); | ||
|
|
||
| let mut cfg = AzblobConfig::default(); | ||
|
|
||
| if let Some(endpoint) = props.get(AZBLOB_ENDPOINT) { | ||
| cfg.endpoint = Some(endpoint.clone()); | ||
| } | ||
| if let Some(account_name) = props.get(AZBLOB_ACCOUNT_NAME) { | ||
| cfg.account_name = Some(account_name.clone()); | ||
| } | ||
| if let Some(account_key) = props.get(AZBLOB_ACCOUNT_KEY) { | ||
| cfg.account_key = Some(account_key.clone()); | ||
| } | ||
| if let Some(sas_token) = props.get(AZBLOB_SAS_TOKEN) { | ||
| cfg.sas_token = Some(sas_token.clone()); | ||
| } | ||
|
|
||
| Ok(cfg) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn test_azblob_config_builder() { | ||
| let config = AzblobConfig::builder() | ||
| .endpoint("https://account.blob.core.windows.net") | ||
| .account_name("myaccount") | ||
| .account_key("my-account-key") | ||
| .build(); | ||
|
|
||
| assert_eq!( | ||
| config.endpoint.as_deref(), | ||
| Some("https://account.blob.core.windows.net") | ||
| ); | ||
| assert_eq!(config.account_name.as_deref(), Some("myaccount")); | ||
| assert_eq!(config.account_key.as_deref(), Some("my-account-key")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_azblob_config_from_storage_config() { | ||
| let storage_config = StorageConfig::new() | ||
| .with_prop(AZBLOB_ENDPOINT, "https://account.blob.core.windows.net") | ||
| .with_prop(AZBLOB_ACCOUNT_NAME, "myaccount") | ||
| .with_prop(AZBLOB_ACCOUNT_KEY, "my-account-key") | ||
| .with_prop(AZBLOB_SAS_TOKEN, "my-sas-token"); | ||
|
|
||
| let azblob_config = AzblobConfig::try_from(&storage_config).unwrap(); | ||
|
|
||
| assert_eq!( | ||
| azblob_config.endpoint.as_deref(), | ||
| Some("https://account.blob.core.windows.net") | ||
| ); | ||
| assert_eq!(azblob_config.account_name.as_deref(), Some("myaccount")); | ||
| assert_eq!(azblob_config.account_key.as_deref(), Some("my-account-key")); | ||
| assert_eq!(azblob_config.sas_token.as_deref(), Some("my-sas-token")); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find a java implementation for azblob so that isn't incorrect but I did notice something that doesn't quite seem correct about the
azdlsconfig (pre-existing not this PR). It seems that we're usingadls.account-namecompared to java'sadls.auth.shared-key.account.namewhich I think causes issues when we get the config back from the catalog for vended credentials.Maybe we need to bottom this out before we commit to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah but this does match py-iceberg https://github.com/apache/iceberg-python/blob/main/pyiceberg/io/__init__.py#L89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay Claude did a little audit for me and found that py-iceberg and java use GCS_SERVICE_HOST = "gcs.service.host" and we use
gcs.service.pathso it would seem we're inconsistent here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took another look at this. The configuration required by Azblob is effectively the same as Azdls; the only difference is the property prefix (azblob.* vs. adls.*).
Would you prefer keeping the dedicated azblob.* keys, or following PyIceberg’s convention and reusing the existing adls.* keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we do really want different clients to expect the same properties, having said that the fact that python accepts the same for both is maybe a little confusing to me but I’ve never used the older blob storage so I’m not sure how reasonable it is to couple the properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both PyArrow and Arrow C++, the logic is to automatically detect whether HNS is enabled and then use different APIs.
For example, in azurefs.cc:
However, OpenDAL cannot do this. Therefore, I think it is reasonable to keep the dedicated Azblob configuration here. The caller needs to explicitly specify whether the namespace is DLS or Blob.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the separate storage impl makes sense to me, I guess my question is just if we should reuse the same config keys or not. I'm leaning towards yes? @CTTY or @blackmwk might have stronger opinions here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, I see two options:
The Azblob and Azdls implementations would remain separate in either case. It sounds like you are leaning toward the second option. Could you confirm that this is what you had in mind? If so, I’ll update the PR accordingly.