Skip to content

Commit be53013

Browse files
Support azure-datalake-store 1.x in AzureDataLakeHook (#73819)
* Support azure-datalake-store 1.x in AzureDataLakeHook * Require azure-datalake-store>=1.0.1 and drop 0.0.x support
1 parent 18af650 commit be53013

7 files changed

Lines changed: 43 additions & 57 deletions

File tree

‎providers/microsoft/azure/README.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ PIP package Version required
5555
========================================== ===================
5656
``apache-airflow`` ``>=2.11.0``
5757
``apache-airflow-providers-common-compat`` ``>=1.13.0``
58-
``adlfs`` ``>=2023.10.0``
58+
``adlfs`` ``>=2026.5.0``
5959
``aiohttp`` ``>=3.14.0``
6060
``azure-batch`` ``>=15.0.0``
6161
``azure-ai-projects`` ``>=2.2.0``
6262
``azure-cosmos`` ``>=4.15.0``
6363
``azure-mgmt-cosmosdb`` ``>=9.9.0``
64-
``azure-datalake-store`` ``>=0.0.45,<1``
64+
``azure-datalake-store`` ``>=1.0.1``
6565
``azure-identity`` ``>=1.25.3``
6666
``azure-keyvault-secrets`` ``>=4.10.0``
6767
``azure-mgmt-datalake-store`` ``>=0.5.0``

‎providers/microsoft/azure/docs/index.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ PIP package Version required
111111
========================================== ===================
112112
``apache-airflow`` ``>=2.11.0``
113113
``apache-airflow-providers-common-compat`` ``>=1.13.0``
114-
``adlfs`` ``>=2023.10.0``
114+
``adlfs`` ``>=2026.5.0``
115115
``aiohttp`` ``>=3.14.0``
116116
``azure-batch`` ``>=15.0.0``
117117
``azure-ai-projects`` ``>=2.2.0``
118118
``azure-cosmos`` ``>=4.15.0``
119119
``azure-mgmt-cosmosdb`` ``>=9.9.0``
120-
``azure-datalake-store`` ``>=0.0.45,<1``
120+
``azure-datalake-store`` ``>=1.0.1``
121121
``azure-identity`` ``>=1.25.3``
122122
``azure-keyvault-secrets`` ``>=4.10.0``
123123
``azure-mgmt-datalake-store`` ``>=0.5.0``

‎providers/microsoft/azure/pyproject.toml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,14 @@ requires-python = ">=3.10"
6161
dependencies = [
6262
"apache-airflow>=2.11.0",
6363
"apache-airflow-providers-common-compat>=1.13.0",
64-
"adlfs>=2023.10.0",
64+
"adlfs>=2026.5.0",
6565
"aiohttp>=3.14.0",
6666
"azure-batch>=15.0.0",
6767
# 2.2.0 adds force deletion support for Hosted agents and agent versions.
6868
"azure-ai-projects>=2.2.0",
6969
"azure-cosmos>=4.15.0",
7070
"azure-mgmt-cosmosdb>=9.9.0",
71-
# 1.x removed lib.auth used by AzureDataLakeHook; remove the cap once the hook supports 1.x,
72-
# tracked at https://github.com/apache/airflow/issues/73795
73-
"azure-datalake-store>=0.0.45,<1",
71+
"azure-datalake-store>=1.0.1",
7472
"azure-identity>=1.25.3",
7573
"azure-keyvault-secrets>=4.10.0",
7674
"azure-mgmt-datalake-store>=0.5.0",

‎providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/data_lake.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from typing import Any, cast
2222

2323
from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError
24-
from azure.datalake.store import core, lib, multithread
24+
from azure.datalake.store import core, multithread
2525
from azure.identity import ClientSecretCredential, DefaultAzureCredential
2626
from azure.storage.filedatalake import (
2727
DataLakeDirectoryClient,
@@ -34,13 +34,12 @@
3434

3535
from airflow.providers.common.compat.sdk import AirflowException, BaseHook
3636
from airflow.providers.microsoft.azure.utils import (
37-
AzureIdentityCredentialAdapter,
3837
add_managed_identity_connection_widgets,
3938
get_field,
4039
get_sync_default_azure_credential,
4140
)
4241

43-
Credentials = ClientSecretCredential | AzureIdentityCredentialAdapter | DefaultAzureCredential
42+
Credentials = ClientSecretCredential | DefaultAzureCredential
4443

4544

4645
class AzureDataLakeHook(BaseHook):
@@ -122,11 +121,15 @@ def get_conn(self) -> core.AzureDLFileSystem:
122121
credential: Credentials
123122
tenant = self._get_field(extras, "tenant")
124123
if tenant:
125-
credential = lib.auth(tenant_id=tenant, client_secret=conn.password, client_id=conn.login)
124+
credential = ClientSecretCredential(
125+
tenant_id=tenant,
126+
client_id=cast("str", conn.login),
127+
client_secret=cast("str", conn.password),
128+
)
126129
else:
127130
managed_identity_client_id = self._get_field(extras, "managed_identity_client_id")
128131
workload_identity_tenant_id = self._get_field(extras, "workload_identity_tenant_id")
129-
credential = AzureIdentityCredentialAdapter(
132+
credential = get_sync_default_azure_credential(
130133
managed_identity_client_id=managed_identity_client_id,
131134
workload_identity_tenant_id=workload_identity_tenant_id,
132135
)

‎providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_lake.py‎

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -73,44 +73,36 @@ def setup_connections(self, create_mock_connections):
7373
)
7474
)
7575

76-
@mock.patch(f"{MODULE}.lib", autospec=True)
77-
def test_conn(self, mock_lib):
78-
from azure.datalake.store import core
79-
76+
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
77+
@mock.patch(f"{MODULE}.ClientSecretCredential", autospec=True)
78+
def test_conn_with_tenant_uses_client_secret_credential(self, mock_credential, mock_filesystem):
8079
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
8180

8281
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")
83-
assert hook._conn is None
84-
assert hook.conn_id == "adl_test_key"
85-
assert isinstance(hook.get_conn(), core.AzureDLFileSystem)
86-
assert mock_lib.auth.called
8782

88-
@pytest.mark.usefixtures("connection_without_tenant")
89-
@mock.patch(f"{MODULE}.lib")
90-
@mock.patch(f"{MODULE}.AzureIdentityCredentialAdapter")
91-
def test_fallback_to_azure_identity_credential_adppter_when_tenant_is_not_provided(
92-
self,
93-
mock_azure_identity_credential_adapter,
94-
mock_datalake_store_lib,
95-
):
96-
from azure.datalake.store import core
83+
assert hook.get_conn() is mock_filesystem.return_value
84+
mock_credential.assert_called_once_with(
85+
tenant_id="tenant", client_id="client_id", client_secret="client secret"
86+
)
87+
mock_filesystem.assert_called_once_with(mock_credential.return_value, store_name="accountname")
9788

89+
@pytest.mark.usefixtures("connection_without_tenant")
90+
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
91+
@mock.patch(f"{MODULE}.get_sync_default_azure_credential", autospec=True)
92+
def test_conn_without_tenant_uses_default_azure_credential(self, mock_credential, mock_filesystem):
9893
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
9994

10095
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key_without_tenant")
101-
assert hook._conn is None
102-
assert hook.conn_id == "adl_test_key_without_tenant"
103-
assert isinstance(hook.get_conn(), core.AzureDLFileSystem)
104-
mock_azure_identity_credential_adapter.assert_called()
105-
args = mock_azure_identity_credential_adapter.call_args
106-
assert args.kwargs["managed_identity_client_id"] is None
107-
assert args.kwargs["workload_identity_tenant_id"] is None
108-
mock_datalake_store_lib.auth.assert_not_called()
96+
97+
assert hook.get_conn() is mock_filesystem.return_value
98+
mock_credential.assert_called_once_with(
99+
managed_identity_client_id=None, workload_identity_tenant_id=None
100+
)
101+
mock_filesystem.assert_called_once_with(mock_credential.return_value, store_name="accountname")
109102

110103
@pytest.mark.usefixtures("connection")
111104
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
112-
@mock.patch(f"{MODULE}.lib", autospec=True)
113-
def test_check_for_blob(self, mock_lib, mock_filesystem):
105+
def test_check_for_blob(self, mock_filesystem):
114106
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
115107

116108
mocked_glob = mock_filesystem.return_value.glob
@@ -120,8 +112,7 @@ def test_check_for_blob(self, mock_lib, mock_filesystem):
120112

121113
@pytest.mark.usefixtures("connection")
122114
@mock.patch(f"{MODULE}.multithread.ADLUploader", autospec=True)
123-
@mock.patch(f"{MODULE}.lib", autospec=True)
124-
def test_upload_file(self, mock_lib, mock_uploader):
115+
def test_upload_file(self, mock_uploader):
125116
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
126117

127118
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")
@@ -145,8 +136,7 @@ def test_upload_file(self, mock_lib, mock_uploader):
145136

146137
@pytest.mark.usefixtures("connection")
147138
@mock.patch(f"{MODULE}.multithread.ADLDownloader", autospec=True)
148-
@mock.patch(f"{MODULE}.lib", autospec=True)
149-
def test_download_file(self, mock_lib, mock_downloader):
139+
def test_download_file(self, mock_downloader):
150140
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
151141

152142
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")
@@ -170,8 +160,7 @@ def test_download_file(self, mock_lib, mock_downloader):
170160

171161
@pytest.mark.usefixtures("connection")
172162
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
173-
@mock.patch(f"{MODULE}.lib", autospec=True)
174-
def test_list_glob(self, mock_lib, mock_fs):
163+
def test_list_glob(self, mock_fs):
175164
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
176165

177166
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")
@@ -180,8 +169,7 @@ def test_list_glob(self, mock_lib, mock_fs):
180169

181170
@pytest.mark.usefixtures("connection")
182171
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
183-
@mock.patch(f"{MODULE}.lib", autospec=True)
184-
def test_list_walk(self, mock_lib, mock_fs):
172+
def test_list_walk(self, mock_fs):
185173
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
186174

187175
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")
@@ -190,8 +178,7 @@ def test_list_walk(self, mock_lib, mock_fs):
190178

191179
@pytest.mark.usefixtures("connection")
192180
@mock.patch(f"{MODULE}.core.AzureDLFileSystem", autospec=True)
193-
@mock.patch(f"{MODULE}.lib", autospec=True)
194-
def test_remove(self, mock_lib, mock_fs):
181+
def test_remove(self, mock_fs):
195182
from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook
196183

197184
hook = AzureDataLakeHook(azure_data_lake_conn_id="adl_test_key")

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,6 @@ airbyte-api = "1.x breaks provider tests (#69081)"
16741674
mysql-connector-python = "Releases without wheels for >=3.12 (#60889, #66026)"
16751675
anthropic = "Provider SDK migration is version-sensitive (#72072, #72094)"
16761676
azure-ai-projects = "2.5+ needs openai>=3, broke main (#73621, #73627)"
1677-
azure-datalake-store = "1.x removed lib.auth used by AzureDataLakeHook (#73795)"
16781677

16791678
[tool.uv.pip]
16801679
# Synchroonize with scripts/ci/prek/upgrade_important_versions.py

‎uv.lock‎

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)