Skip to content

Commit 42afc43

Browse files
authored
Fix: Table-Exists if Server returns 204 (#739)
* Fix: Table-Exists if Server returns 204 * Add test for table exist 204 return code
1 parent eba4bee commit 42afc43

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pyiceberg/catalog/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,4 +790,4 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool:
790790
response = self._session.head(
791791
self.url(Endpoints.load_table, prefixed=True, **self._split_identifier_for_path(identifier_tuple))
792792
)
793-
return response.status_code == 200
793+
return response.status_code in (200, 204)

tests/catalog/test_rest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,16 @@ def test_table_exist_200(rest_mock: Mocker) -> None:
691691
assert catalog.table_exists(("fokko", "table"))
692692

693693

694+
def test_table_exist_204(rest_mock: Mocker) -> None:
695+
rest_mock.head(
696+
f"{TEST_URI}v1/namespaces/fokko/tables/table",
697+
status_code=204,
698+
request_headers=TEST_HEADERS,
699+
)
700+
catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
701+
assert catalog.table_exists(("fokko", "table"))
702+
703+
694704
def test_table_exist_500(rest_mock: Mocker) -> None:
695705
rest_mock.head(
696706
f"{TEST_URI}v1/namespaces/fokko/tables/table",

0 commit comments

Comments
 (0)