Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyiceberg/catalog/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,8 @@ def register_table(self, identifier: str | Identifier, metadata_location: str, o
@retry(**_RETRY_ARGS)
@override
def list_tables(self, namespace: str | Identifier) -> list[Identifier]:
self._check_endpoint(Capability.V1_LIST_TABLES)
if Capability.V1_LIST_TABLES not in self._supported_endpoints:
return []
namespace_tuple = self._check_valid_namespace_identifier(namespace)
namespace_concat = self._encode_namespace_path(namespace_tuple)
url = self.url(Endpoints.list_tables, namespace=namespace_concat)
Expand Down Expand Up @@ -1277,7 +1278,8 @@ def drop_namespace(self, namespace: str | Identifier) -> None:
@retry(**_RETRY_ARGS)
@override
def list_namespaces(self, namespace: str | Identifier = ()) -> list[Identifier]:
self._check_endpoint(Capability.V1_LIST_NAMESPACES)
if Capability.V1_LIST_NAMESPACES not in self._supported_endpoints:
return []
namespace_tuple = self.identifier_to_tuple(namespace)

params: dict[str, str] = {}
Expand Down
28 changes: 28 additions & 0 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,34 @@ def test_unsupported_endpoint(self, requests_mock: Mocker) -> None:
with pytest.raises(NotImplementedError, match="Server does not support endpoint"):
catalog._check_endpoint(Capability.V1_LIST_TABLES)

def test_list_tables_returns_empty_when_unsupported(self, requests_mock: Mocker) -> None:
requests_mock.get(
f"{TEST_URI}v1/config",
json={
"defaults": {},
"overrides": {},
"endpoints": ["GET /v1/{prefix}/namespaces"],
},
status_code=200,
)
catalog = RestCatalog("rest", uri=TEST_URI, token="token")

assert catalog.list_tables(("examples",)) == []

def test_list_namespaces_returns_empty_when_unsupported(self, requests_mock: Mocker) -> None:
requests_mock.get(
f"{TEST_URI}v1/config",
json={
"defaults": {},
"overrides": {},
"endpoints": ["GET /v1/{prefix}/namespaces/{namespace}/tables"],
},
status_code=200,
)
catalog = RestCatalog("rest", uri=TEST_URI, token="token")

assert catalog.list_namespaces() == []

def test_config_returns_invalid_endpoint(self, requests_mock: Mocker) -> None:
requests_mock.get(
f"{TEST_URI}v1/config",
Expand Down