Skip to content
Draft
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
2 changes: 1 addition & 1 deletion dev/docker-compose-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
retries: 5
start_period: 90s
rest:
image: apache/iceberg-rest-fixture:1.10.1
image: apache/iceberg-rest-fixture
container_name: pyiceberg-rest
networks:
iceberg_net:
Expand Down
2 changes: 1 addition & 1 deletion dev/spark/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM apache/spark:${BASE_IMAGE_SPARK_VERSION}

# Dependency versions - keep these compatible
# Changing these will invalidate the JAR download cache layer
ARG ICEBERG_VERSION=1.10.1
ARG ICEBERG_VERSION=1.11.0
ARG ICEBERG_SPARK_RUNTIME_VERSION=4.0_2.13
ARG HADOOP_VERSION=3.4.1
ARG AWS_SDK_VERSION=2.24.6
Expand Down
1 change: 1 addition & 0 deletions pyiceberg/catalog/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ def _response_to_staged_table(self, identifier_tuple: tuple[str, ...], table_res
def _response_to_view(self, identifier_tuple: tuple[str, ...], view_response: ViewResponse) -> View:
return View(
identifier=identifier_tuple,
metadata_location=view_response.metadata_location,
metadata=view_response.metadata,
)

Expand Down
3 changes: 3 additions & 0 deletions pyiceberg/view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ class View:

_identifier: Identifier
metadata: ViewMetadata
metadata_location: str | None

def __init__(
self,
identifier: Identifier,
metadata: ViewMetadata,
metadata_location: str | None = None,
) -> None:
self._identifier = identifier
self.metadata = metadata
self.metadata_location = metadata_location

def name(self) -> Identifier:
"""Return the identifier of this view."""
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,11 @@ def clean_up(test_catalog: Catalog) -> None:
if "my_iceberg_database-" in database_name:
for identifier in test_catalog.list_tables(database_name):
test_catalog.drop_table(identifier)
try:
for identifier in test_catalog.list_views(database_name):
test_catalog.drop_view(identifier)
except NotImplementedError:
pass
test_catalog.drop_namespace(database_name)


Expand Down
32 changes: 31 additions & 1 deletion tests/integration/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from pyiceberg.table.sorting import INITIAL_SORT_ORDER_ID, SortField, SortOrder
from pyiceberg.transforms import BucketTransform, DayTransform, IdentityTransform
from pyiceberg.types import IntegerType, LongType, NestedField, TimestampType, UUIDType
from pyiceberg.view.metadata import SQLViewRepresentation, ViewVersion
from tests.conftest import (
clean_up,
does_support_atomic_concurrent_updates,
Expand Down Expand Up @@ -618,7 +619,36 @@ def test_register_table_existing(test_catalog: Catalog, table_schema_nested: Sch


@pytest.mark.integration
@pytest.mark.skip(reason="Requires Iceberg REST Fixtures 1.11.x")
def test_rest_register_view(rest_catalog: RestCatalog, table_schema_simple: Schema, database_name: str, view_name: str) -> None:
identifier = (database_name, view_name)

rest_catalog.create_namespace_if_not_exists(database_name)

view_version = ViewVersion(
version_id=1,
schema_id=1,
timestamp_ms=1,
summary={},
representations=[
SQLViewRepresentation(
type="sql",
sql="SELECT 1 as some_col",
dialect="spark",
)
],
default_namespace=["default"],
)

view = rest_catalog.create_view(identifier, table_schema_simple, view_version)
assert rest_catalog.view_exists(identifier)

register_identifier = (database_name, "register_identifier")
assert not rest_catalog.view_exists(register_identifier)
rest_catalog.register_view(register_identifier, view.metadata_location)
assert rest_catalog.view_exists(register_identifier)


@pytest.mark.integration
def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema_simple: Schema) -> None:
"""
Tests that the REST catalog correctly picks up the namespace-separator from the config endpoint.
Expand Down
Loading