-
Notifications
You must be signed in to change notification settings - Fork 466
Support ADLS with Pyarrow file IO #2111
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
Changes from 9 commits
494f2fe
5efd4ee
076b68b
9a8ce25
f609160
9667b31
3ab3e99
018125f
d96f858
7e513eb
3e36526
5a6dd72
dae20c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,13 @@ | |
| ) | ||
| from pyiceberg.expressions.visitors import visit as boolean_expression_visit | ||
| from pyiceberg.io import ( | ||
| ADLS_ACCOUNT_KEY, | ||
| ADLS_ACCOUNT_NAME, | ||
| ADLS_BLOB_STORAGE_AUTHORITY, | ||
| ADLS_BLOB_STORAGE_SCHEME, | ||
| ADLS_DFS_STORAGE_AUTHORITY, | ||
| ADLS_DFS_STORAGE_SCHEME, | ||
| ADLS_SAS_TOKEN, | ||
| AWS_ACCESS_KEY_ID, | ||
| AWS_REGION, | ||
| AWS_ROLE_ARN, | ||
|
|
@@ -197,6 +204,7 @@ | |
| MAP_VALUE_NAME = "value" | ||
| DOC = "doc" | ||
| UTC_ALIASES = {"UTC", "+00:00", "Etc/UTC", "Z"} | ||
| MIN_PYARROW_VERSION_SUPPORTING_AZURE_FS = "20.0.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: inline this at the function level
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then I will have to keep in sync the version used in tests and this one... I can do it if it's ok for you
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think thats fine, we can just use This is technically a "public" variable and I dont want users to be able to import it. |
||
|
|
||
| T = TypeVar("T") | ||
|
|
||
|
|
@@ -394,6 +402,9 @@ def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSyste | |
| elif scheme in {"gs", "gcs"}: | ||
| return self._initialize_gcs_fs() | ||
|
|
||
| elif scheme in {"abfs", "abfss", "wasb", "wasbs"}: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cant find any pyarrow docs that indicates |
||
| return self._initialize_azure_fs() | ||
|
|
||
| elif scheme in {"file"}: | ||
| return self._initialize_local_fs() | ||
|
|
||
|
|
@@ -475,6 +486,42 @@ def _initialize_s3_fs(self, netloc: Optional[str]) -> FileSystem: | |
|
|
||
| return S3FileSystem(**client_kwargs) | ||
|
|
||
| def _initialize_azure_fs(self) -> FileSystem: | ||
| from packaging import version | ||
|
|
||
| if version.parse(pyarrow.__version__) < version.parse(MIN_PYARROW_VERSION_SUPPORTING_AZURE_FS): | ||
| raise ImportError( | ||
| f"pyarrow version >= {MIN_PYARROW_VERSION_SUPPORTING_AZURE_FS} required for AzureFileSystem support, " | ||
| f"but found version {pyarrow.__version__}." | ||
| ) | ||
|
|
||
| from pyarrow.fs import AzureFileSystem | ||
|
|
||
| client_kwargs: Dict[str, str] = {} | ||
|
|
||
| if account_name := self.properties.get(ADLS_ACCOUNT_NAME): | ||
| client_kwargs["account_name"] = account_name | ||
|
|
||
| if account_key := self.properties.get(ADLS_ACCOUNT_KEY): | ||
| client_kwargs["account_key"] = account_key | ||
|
|
||
| if blob_storage_authority := self.properties.get(ADLS_BLOB_STORAGE_AUTHORITY): | ||
| client_kwargs["blob_storage_authority"] = blob_storage_authority | ||
|
|
||
| if dfs_storage_authority := self.properties.get(ADLS_DFS_STORAGE_AUTHORITY): | ||
| client_kwargs["dfs_storage_authority"] = dfs_storage_authority | ||
|
|
||
| if blob_storage_scheme := self.properties.get(ADLS_BLOB_STORAGE_SCHEME): | ||
| client_kwargs["blob_storage_scheme"] = blob_storage_scheme | ||
|
|
||
| if dfs_storage_scheme := self.properties.get(ADLS_DFS_STORAGE_SCHEME): | ||
| client_kwargs["dfs_storage_scheme"] = dfs_storage_scheme | ||
|
|
||
| if sas_token := self.properties.get(ADLS_SAS_TOKEN): | ||
| client_kwargs["sas_token"] = sas_token | ||
|
|
||
| return AzureFileSystem(**client_kwargs) | ||
|
kevinjqliu marked this conversation as resolved.
|
||
|
|
||
| def _initialize_hdfs_fs(self, scheme: str, netloc: Optional[str]) -> FileSystem: | ||
| from pyarrow.fs import HadoopFileSystem | ||
|
|
||
|
|
||
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.
we should add these to the docs https://py.iceberg.apache.org/configuration/#azure-data-lake
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.
Done