This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 42afc439 Fix: Table-Exists if Server returns 204 (#739)
42afc439 is described below

commit 42afc439d362ef1b3dcff03a1ffd959bc0a399ca
Author: Christian <[email protected]>
AuthorDate: Thu May 23 11:41:10 2024 +0200

    Fix: Table-Exists if Server returns 204 (#739)
    
    * Fix: Table-Exists if Server returns 204
    
    * Add test for table exist 204 return code
---
 pyiceberg/catalog/rest.py  |  2 +-
 tests/catalog/test_rest.py | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py
index 7259f9fa..afd58186 100644
--- a/pyiceberg/catalog/rest.py
+++ b/pyiceberg/catalog/rest.py
@@ -790,4 +790,4 @@ class RestCatalog(Catalog):
         response = self._session.head(
             self.url(Endpoints.load_table, prefixed=True, 
**self._split_identifier_for_path(identifier_tuple))
         )
-        return response.status_code == 200
+        return response.status_code in (200, 204)
diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py
index ec5a6a22..b5c626d6 100644
--- a/tests/catalog/test_rest.py
+++ b/tests/catalog/test_rest.py
@@ -691,6 +691,16 @@ def test_table_exist_200(rest_mock: Mocker) -> None:
     assert catalog.table_exists(("fokko", "table"))
 
 
+def test_table_exist_204(rest_mock: Mocker) -> None:
+    rest_mock.head(
+        f"{TEST_URI}v1/namespaces/fokko/tables/table",
+        status_code=204,
+        request_headers=TEST_HEADERS,
+    )
+    catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
+    assert catalog.table_exists(("fokko", "table"))
+
+
 def test_table_exist_500(rest_mock: Mocker) -> None:
     rest_mock.head(
         f"{TEST_URI}v1/namespaces/fokko/tables/table",

Reply via email to