Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv-io committed Jan 19, 2025
1 parent 7586e87 commit c028042
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/test_writes/test_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c028042

Please sign in to comment.