From 567f4c08e628f06be217215de700090b8a9470aa Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 11 Sep 2025 13:56:08 +0100 Subject: [PATCH 1/5] Fix prefix match for ADLS_SAS_TOKEN. --- pyiceberg/io/fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py index 310402645a..ce87f14ed1 100644 --- a/pyiceberg/io/fsspec.py +++ b/pyiceberg/io/fsspec.py @@ -207,7 +207,7 @@ def _adls(properties: Properties) -> AbstractFileSystem: from azure.core.credentials_async import AsyncTokenCredential for key, sas_token in { - key.replace(f"{ADLS_SAS_TOKEN}.", ""): value for key, value in properties.items() if key.startswith(ADLS_SAS_TOKEN) + key.replace(f"{ADLS_SAS_TOKEN}.", ""): value for key, value in properties.items() if key.startswith(f"{ADLS_SAS_TOKEN}.") }.items(): if ADLS_ACCOUNT_NAME not in properties: properties[ADLS_ACCOUNT_NAME] = key.split(".")[0] From 4bdc80c3b59d4b3094f7c816565b9a72a783c35c Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 12 Sep 2025 14:35:45 +0100 Subject: [PATCH 2/5] Add unit test --- tests/io/test_fsspec.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index e03310cb55..b8d685a360 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -508,6 +508,34 @@ def test_fsspec_pickle_round_trip_aldfs(adls_fsspec_fileio: FsspecFileIO) -> Non _test_fsspec_pickle_round_trip(adls_fsspec_fileio, "abfss://tests/foo.txt") +@pytest.mark.adls +def test_adls_account_name_sas_token_extraction() -> None: + session_properties: Properties = { + "adls.tenant-id": "test-tenant-id", + "adls.account-host": "testaccount.dfs.core.windows.net", + "adls.sas-token-expires-at-ms.testaccount.dfs.core.windows.net": "1757597218121", + "adls.sas-token-expires-at-ms.testaccount": "test-sas-token" + } + + with mock.patch("adfls.AzureBlobFileSystem") as mock_adfls: + adls_fileio = FsspecFileIO(properties=session_properties) + filename = str(uuid.uuid4()) + + adls_fileio.new_input(location=f"abfss://tests/{filename}") + + mock_adfls.assert_called_with( + connection_string=None, + credential=None, + account_name="testaccount", + account_key=None, + sas_token="test-sas-token", + tenant_id="test-tenant-id", + client_id=None, + client_secret=None, + account_host="testaccount.dfs.core.windows.net", + ) + + @pytest.mark.gcs def test_fsspec_new_input_file_gcs(fsspec_fileio_gcs: FsspecFileIO) -> None: """Test creating a new input file from a fsspec file-io""" From 47da05ce897ccd682fd94ff3adc14d5a45fabae6 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Sat, 13 Sep 2025 08:10:50 +0100 Subject: [PATCH 3/5] fix linting --- tests/io/test_fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index b8d685a360..cbbc8838c3 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -514,7 +514,7 @@ def test_adls_account_name_sas_token_extraction() -> None: "adls.tenant-id": "test-tenant-id", "adls.account-host": "testaccount.dfs.core.windows.net", "adls.sas-token-expires-at-ms.testaccount.dfs.core.windows.net": "1757597218121", - "adls.sas-token-expires-at-ms.testaccount": "test-sas-token" + "adls.sas-token-expires-at-ms.testaccount": "test-sas-token", } with mock.patch("adfls.AzureBlobFileSystem") as mock_adfls: From dfca05cf7e1497f27bfea099220c5d7003ddd0b8 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Mon, 15 Sep 2025 13:49:02 +0100 Subject: [PATCH 4/5] typo --- tests/io/test_fsspec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index cbbc8838c3..97400a2ce2 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -517,13 +517,13 @@ def test_adls_account_name_sas_token_extraction() -> None: "adls.sas-token-expires-at-ms.testaccount": "test-sas-token", } - with mock.patch("adfls.AzureBlobFileSystem") as mock_adfls: + with mock.patch("adlfs.AzureBlobFileSystem") as mock_adlfs: adls_fileio = FsspecFileIO(properties=session_properties) filename = str(uuid.uuid4()) adls_fileio.new_input(location=f"abfss://tests/{filename}") - mock_adfls.assert_called_with( + mock_adlfs.assert_called_with( connection_string=None, credential=None, account_name="testaccount", From 53d3eb162dade7a672ece110af6dbad70b269e4f Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Tue, 16 Sep 2025 17:52:10 +0100 Subject: [PATCH 5/5] Fix failing ADLS test. --- tests/io/test_fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index 97400a2ce2..1f8b3f42fa 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -513,8 +513,8 @@ def test_adls_account_name_sas_token_extraction() -> None: session_properties: Properties = { "adls.tenant-id": "test-tenant-id", "adls.account-host": "testaccount.dfs.core.windows.net", + "adls.sas-token.testaccount.dfs.core.windows.net": "test-sas-token", "adls.sas-token-expires-at-ms.testaccount.dfs.core.windows.net": "1757597218121", - "adls.sas-token-expires-at-ms.testaccount": "test-sas-token", } with mock.patch("adlfs.AzureBlobFileSystem") as mock_adlfs: