You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2026/09/02 18:31:27 UTC
(iceberg-python) branch main updated: Add create view catalog tests (#3887)
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 47ba4aa8c Add create view catalog tests (#3887)
47ba4aa8c is described below
commit 47ba4aa8c7eebd9b10116859e94d20b626adbc4d
Author: Alex Stephen <13...@users.noreply.github.com>
AuthorDate: Wed Sep 2 11:31:21 2026 -0700
Add create view catalog tests (#3887)
add view catalog tests
---
tests/integration/test_catalog.py | 54 +++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/tests/integration/test_catalog.py b/tests/integration/test_catalog.py
index 457f5e90c..3765b296e 100644
--- a/tests/integration/test_catalog.py
+++ b/tests/integration/test_catalog.py
@@ -44,9 +44,9 @@ from pyiceberg.schema import INITIAL_SCHEMA_ID, Schema
from pyiceberg.table.metadata import INITIAL_SPEC_ID
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.types import IntegerType, LongType, NestedField, StringType, TimestampType, UUIDType
from pyiceberg.view import View
-from pyiceberg.view.metadata import ViewMetadata
+from pyiceberg.view.metadata import SQLViewRepresentation, ViewMetadata, ViewRepresentation, ViewVersion
from tests.conftest import (
clean_up,
does_support_atomic_concurrent_updates,
@@ -620,6 +620,56 @@ def test_register_table_existing(test_catalog: Catalog, table_schema_nested: Sch
test_catalog.register_table(identifier, metadata_location=table.metadata_location)
+@pytest.mark.integration
+def test_rest_basic_create_view(rest_catalog: RestCatalog, database_name: str, view_name: str) -> None:
+ """Ported from Java's ViewCatalogTests#basicCreateView."""
+ identifier = (database_name, view_name)
+
+ rest_catalog.create_namespace_if_not_exists(database_name)
+ assert not rest_catalog.view_exists(identifier)
+
+ view = rest_catalog.create_view(
+ identifier,
+ schema=Schema(
+ NestedField(field_id=3, name="id", field_type=IntegerType(), required=True, doc="unique ID"),
+ NestedField(field_id=4, name="data", field_type=StringType(), required=True),
+ schema_id=5,
+ ),
+ view_version=ViewVersion(
+ version_id=1,
+ schema_id=0,
+ representations=[ViewRepresentation(SQLViewRepresentation(type="sql", sql="select * from ns.tbl", dialect="spark"))],
+ default_namespace=(database_name,),
+ ),
+ )
+
+ assert rest_catalog.view_exists(identifier)
+ assert view.name() == identifier
+ assert len(view.history()) == 1
+ assert view.history()[0].version_id == 1
+ assert view.schema().schema_id == 0
+
+ assert (
+ view.schema().as_struct()
+ == Schema(
+ NestedField(field_id=1, name="id", field_type=IntegerType(), required=True, doc="unique ID"),
+ NestedField(field_id=2, name="data", field_type=StringType(), required=True),
+ ).as_struct()
+ )
+ assert list(view.schemas().keys()) == [0]
+ assert view.versions == [view.current_version()]
+
+ current_version = view.current_version()
+ assert current_version == ViewVersion(
+ version_id=1,
+ schema_id=0,
+ timestamp_ms=current_version.timestamp_ms,
+ summary=current_version.summary,
+ representations=[ViewRepresentation(SQLViewRepresentation(type="sql", sql="select * from ns.tbl", dialect="spark"))],
+ default_namespace=(database_name,),
+ )
+
+
@pytest.mark.integration
def test_rest_list_views(
rest_catalog: RestCatalog, example_view_metadata_v1: dict[str, Any], database_name: str, view_name: str