Skip to content

Commit b59b73c

Browse files
committed
monkeypatch AzureBlobFileSystem._strip_protocol
1 parent 6d13217 commit b59b73c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pyiceberg/io/fsspec.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ def _adls(properties: Properties) -> AbstractFileSystem:
206206
from azure.core.credentials import AccessToken
207207
from azure.core.credentials_async import AsyncTokenCredential
208208

209+
# Monkeypatch AzureBlobFileSystem._strip_protocol function
210+
# adlfs expects abfs/abfss. For compatibility, convert wasb/wasbs to abfs/abfss
211+
_original_strip_protocol = AzureBlobFileSystem._strip_protocol
212+
213+
def strip_protocol_patch(cls, path: str): # type: ignore
214+
path = path.replace("wasb://", "abfs://").replace("wasbs://", "abfss://")
215+
return _original_strip_protocol(path)
216+
217+
AzureBlobFileSystem._strip_protocol = classmethod(strip_protocol_patch)
218+
209219
for key, sas_token in {
210220
key.replace(f"{ADLS_SAS_TOKEN}.", ""): value for key, value in properties.items() if key.startswith(ADLS_SAS_TOKEN)
211221
}.items():

0 commit comments

Comments
 (0)