|
26 | 26 | from pyiceberg.catalog.rest import RestCatalog |
27 | 27 | from pyiceberg.exceptions import NoSuchViewError |
28 | 28 | from pyiceberg.schema import Schema |
| 29 | +from pyiceberg.types import BooleanType, LongType, NestedField, StringType |
29 | 30 | from pyiceberg.view.metadata import SQLViewRepresentation, ViewVersion |
30 | 31 |
|
31 | 32 | TEST_NAMESPACE_IDENTIFIER = "TEST NS" |
@@ -85,20 +86,26 @@ def test_replace_table_end_to_end_against_rest_server(catalog: Catalog) -> None: |
85 | 86 | if catalog.table_exists(identifier): |
86 | 87 | catalog.drop_table(identifier) |
87 | 88 |
|
88 | | - pa_table = pa.Table.from_pydict( |
89 | | - {"id": [1, 2, 3], "data": ["a", "b", "c"]}, |
90 | | - schema=pa.schema([pa.field("id", pa.int64()), pa.field("data", pa.large_string())]), |
| 89 | + original_schema = Schema( |
| 90 | + NestedField(field_id=1, name="id", field_type=LongType(), required=False), |
| 91 | + NestedField(field_id=2, name="data", field_type=StringType(), required=False), |
| 92 | + ) |
| 93 | + original = catalog.create_table(identifier, schema=original_schema) |
| 94 | + original.append( |
| 95 | + pa.Table.from_pydict( |
| 96 | + {"id": [1, 2, 3], "data": ["a", "b", "c"]}, |
| 97 | + schema=pa.schema([pa.field("id", pa.int64()), pa.field("data", pa.large_string())]), |
| 98 | + ) |
91 | 99 | ) |
92 | | - original = catalog.create_table(identifier, schema=pa_table.schema) |
93 | | - original.append(pa_table) |
94 | 100 | original.refresh() |
95 | 101 | original_snapshot_id = original.current_snapshot().snapshot_id # type: ignore[union-attr] |
96 | 102 |
|
97 | | - new_data = pa.Table.from_pydict( |
98 | | - {"id": [10], "name": ["alice"], "active": [True]}, |
99 | | - schema=pa.schema([pa.field("id", pa.int64()), pa.field("name", pa.large_string()), pa.field("active", pa.bool_())]), |
| 103 | + new_schema = Schema( |
| 104 | + NestedField(field_id=1, name="id", field_type=LongType(), required=False), |
| 105 | + NestedField(field_id=2, name="name", field_type=StringType(), required=False), |
| 106 | + NestedField(field_id=3, name="active", field_type=BooleanType(), required=False), |
100 | 107 | ) |
101 | | - replaced = catalog.replace_table(identifier, schema=new_data.schema) |
| 108 | + replaced = catalog.replace_table(identifier, schema=new_schema) |
102 | 109 |
|
103 | 110 | assert replaced.metadata.table_uuid == original.metadata.table_uuid |
104 | 111 | assert replaced.current_snapshot() is None |
|
0 commit comments