From c02804281eb55e0395b54246bc4b2a54b6fc5cd6 Mon Sep 17 00:00:00 2001 From: Shiv Gupta <18354771+shiv-io@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:42:26 +0000 Subject: [PATCH] Add integration test --- pyiceberg/catalog/rest.py | 5 ++--- tests/integration/test_writes/test_writes.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 861bac73e0..76a64fc8a7 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -917,15 +917,14 @@ def view_exists(self, identifier: Union[str, Identifier]) -> bool: Returns: bool: True if the view exists, False otherwise. """ - identifier_tuple = self._identifier_to_tuple_without_catalog(identifier) response = self._session.head( self.url( - Endpoints.view_exists, prefixed=True, **self._split_identifier_for_path(identifier_tuple, IdentifierKind.VIEW) + Endpoints.view_exists, prefixed=True, **self._split_identifier_for_path(identifier, IdentifierKind.VIEW) ), ) if response.status_code == 404: return False - elif response.status_code == 204: + elif response.status_code in [200, 204]: return True try: diff --git a/tests/integration/test_writes/test_writes.py b/tests/integration/test_writes/test_writes.py index fff48b9373..5a0af656bd 100644 --- a/tests/integration/test_writes/test_writes.py +++ b/tests/integration/test_writes/test_writes.py @@ -1424,6 +1424,18 @@ def test_table_v1_with_null_nested_namespace(session_catalog: Catalog, arrow_tab # We expect no error here session_catalog.drop_table(identifier) +@pytest.mark.integration +def test_view_exists(spark: SparkSession, session_catalog: Catalog,) -> None: + identifier = "default.some_view" + spark.sql( + f""" + CREATE VIEW {identifier} + AS + (SELECT 1 as some_col) + """ + ).collect() + assert session_catalog.view_exists(identifier) + session_catalog.drop_view(identifier) # clean up @pytest.mark.integration def test_overwrite_all_data_with_filter(session_catalog: Catalog) -> None: