|
44 | 44 | from pyiceberg.table.sorting import INITIAL_SORT_ORDER_ID, SortField, SortOrder |
45 | 45 | from pyiceberg.transforms import BucketTransform, DayTransform, IdentityTransform |
46 | 46 | from pyiceberg.types import IntegerType, LongType, NestedField, TimestampType, UUIDType |
| 47 | +from pyiceberg.view.metadata import SQLViewRepresentation, ViewVersion |
47 | 48 | from tests.conftest import ( |
48 | 49 | clean_up, |
49 | 50 | does_support_atomic_concurrent_updates, |
@@ -617,6 +618,36 @@ def test_register_table_existing(test_catalog: Catalog, table_schema_nested: Sch |
617 | 618 | test_catalog.register_table(identifier, metadata_location=table.metadata_location) |
618 | 619 |
|
619 | 620 |
|
| 621 | +@pytest.mark.integration |
| 622 | +def test_rest_register_view(rest_catalog: RestCatalog, table_schema_simple: Schema, database_name: str, view_name: str) -> None: |
| 623 | + identifier = (database_name, view_name) |
| 624 | + |
| 625 | + rest_catalog.create_namespace_if_not_exists(database_name) |
| 626 | + |
| 627 | + view_version = ViewVersion( |
| 628 | + version_id=1, |
| 629 | + schema_id=1, |
| 630 | + timestamp_ms=1, |
| 631 | + summary={}, |
| 632 | + representations=[ |
| 633 | + SQLViewRepresentation( |
| 634 | + type="sql", |
| 635 | + sql="SELECT 1 as some_col", |
| 636 | + dialect="spark", |
| 637 | + ) |
| 638 | + ], |
| 639 | + default_namespace=["default"], |
| 640 | + ) |
| 641 | + |
| 642 | + view = rest_catalog.create_view(identifier, table_schema_simple, view_version) |
| 643 | + assert rest_catalog.view_exists(identifier) |
| 644 | + |
| 645 | + register_identifier = (database_name, "register_identifier") |
| 646 | + assert not rest_catalog.view_exists(register_identifier) |
| 647 | + rest_catalog.register_view(register_identifier, view.metadata_location) |
| 648 | + assert rest_catalog.view_exists(register_identifier) |
| 649 | + |
| 650 | + |
620 | 651 | @pytest.mark.integration |
621 | 652 | def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema_simple: Schema) -> None: |
622 | 653 | """ |
|
0 commit comments