diff --git a/pyiceberg/io/__init__.py b/pyiceberg/io/__init__.py index 7dbc651214..b017b431cb 100644 --- a/pyiceberg/io/__init__.py +++ b/pyiceberg/io/__init__.py @@ -99,6 +99,11 @@ GCS_VERSION_AWARE = "gcs.version-aware" HF_ENDPOINT = "hf.endpoint" HF_TOKEN = "hf.token" +COS_SECRET_ID = "cos.secret-id" +COS_SECRET_KEY = "cos.secret-key" +COS_SESSION_TOKEN = "cos.session-token" +COS_REGION = "cos.region" +COS_ENDPOINT = "cos.endpoint" @runtime_checkable @@ -314,6 +319,8 @@ def delete(self, location: str | InputFile | OutputFile) -> None: "wasb": [FSSPEC_FILE_IO, ARROW_FILE_IO], "wasbs": [FSSPEC_FILE_IO, ARROW_FILE_IO], "hf": [FSSPEC_FILE_IO], + "cosn": [FSSPEC_FILE_IO], + "cos": [FSSPEC_FILE_IO], } diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py index 63ec55bab4..fdfaed291f 100644 --- a/pyiceberg/io/fsspec.py +++ b/pyiceberg/io/fsspec.py @@ -88,6 +88,11 @@ InputStream, OutputFile, OutputStream, + COS_ENDPOINT, + COS_REGION, + COS_SECRET_ID, + COS_SECRET_KEY, + COS_SESSION_TOKEN, ) from pyiceberg.typedef import Properties from pyiceberg.types import strtobool @@ -303,6 +308,18 @@ def _hf(properties: Properties) -> AbstractFileSystem: token=properties.get(HF_TOKEN), ) +def _cosn(properties: Properties) -> AbstractFileSystem: + from cosfs import CosFileSystem + + token = properties.get(COS_SESSION_TOKEN) or None + + return CosFileSystem( + secret_id=properties.get(COS_SECRET_ID), + secret_key=properties.get(COS_SECRET_KEY), + token=token, + endpoint=properties.get(COS_ENDPOINT), + region=properties.get(COS_REGION), + ) SCHEME_TO_FS: dict[str, Callable[..., AbstractFileSystem]] = { "": _file, @@ -315,6 +332,8 @@ def _hf(properties: Properties) -> AbstractFileSystem: "gs": _gs, "gcs": _gs, "hf": _hf, + "cosn": _cosn, + "cos": _cosn, } _ADLS_SCHEMES = frozenset({"abfs", "abfss", "wasb", "wasbs"}) diff --git a/pyproject.toml b/pyproject.toml index 421f90c933..1925626896 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,6 +98,7 @@ datafusion = ["datafusion>=52,<53"] gcp-auth = ["google-auth>=2.4.0"] entra-auth = ["azure-identity>=1.25.1"] geoarrow = ["geoarrow-pyarrow>=0.2.0"] +cosfs = ["cosfs>=2026.3.25"] [dependency-groups] dev = [