3434 TableAlreadyExistsError ,
3535)
3636from pyiceberg .io import WAREHOUSE
37- from pyiceberg .partitioning import UNPARTITIONED_PARTITION_SPEC , PartitionSpec
37+ from pyiceberg .partitioning import PartitionField , PartitionSpec
3838from pyiceberg .schema import INITIAL_SCHEMA_ID , Schema
3939from pyiceberg .table .metadata import INITIAL_SPEC_ID
4040from pyiceberg .table .sorting import INITIAL_SORT_ORDER_ID , SortField , SortOrder
41- from pyiceberg .transforms import IdentityTransform
42- from pyiceberg .types import IntegerType , LongType , UUIDType
41+ from pyiceberg .transforms import DayTransform , IdentityTransform
42+ from pyiceberg .types import IntegerType , LongType , NestedField , TimestampType , UUIDType
4343from tests .conftest import clean_up
4444
4545
@@ -233,17 +233,20 @@ def test_update_table_transaction(test_catalog: Catalog, test_schema: Schema, ta
233233 table = test_catalog .create_table (identifier , test_schema )
234234 assert test_catalog .table_exists (identifier )
235235
236- expected_schema : Schema = Schema ()
237- expected_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC
236+ expected_schema = Schema (
237+ NestedField (1 , "VendorID" , IntegerType (), False ),
238+ NestedField (2 , "tpep_pickup_datetime" , TimestampType (), False ),
239+ NestedField (3 , "new_col" , IntegerType (), False ),
240+ )
241+
242+ expected_spec = PartitionSpec (PartitionField (3 , 1000 , IdentityTransform (), "new_col" ))
238243
239244 with table .transaction () as transaction :
240245 with transaction .update_schema () as update_schema :
241246 update_schema .add_column ("new_col" , IntegerType ())
242- expected_schema = update_schema ._apply ()
243247
244248 with transaction .update_spec () as update_spec :
245249 update_spec .add_field ("new_col" , IdentityTransform ())
246- expected_spec = update_spec ._apply ()
247250
248251 table = test_catalog .load_table (identifier )
249252 assert table .schema ().as_struct () == expected_schema .as_struct ()
@@ -266,9 +269,10 @@ def test_update_schema_conflict(test_catalog: Catalog, test_schema: Schema, tabl
266269
267270 # Update schema concurrently so that the original update fails
268271 concurrent_update = test_catalog .load_table (identifier ).update_schema ().delete_column ("VendorID" )
269- expected_schema = concurrent_update ._apply ()
270272 concurrent_update .commit ()
271273
274+ expected_schema = Schema (NestedField (2 , "tpep_pickup_datetime" , TimestampType (), False ))
275+
272276 with pytest .raises (CommitFailedException ):
273277 original_update .commit ()
274278
@@ -322,8 +326,18 @@ def test_create_table_transaction_multiple_schemas(
322326
323327 # TODO: test replace sort order when available
324328
325- expected_schema = table_transaction .update_schema ()._apply ()
326- expected_spec = table_transaction .update_spec ()._apply ()
329+ expected_schema = Schema (
330+ NestedField (1 , "VendorID" , IntegerType (), False ),
331+ NestedField (2 , "tpep_pickup_datetime" , TimestampType (), False ),
332+ NestedField (3 , "new_col" , IntegerType (), False ),
333+ NestedField (4 , "new_col_1" , UUIDType (), False ),
334+ )
335+
336+ expected_spec = PartitionSpec (
337+ PartitionField (1 , 1000 , IdentityTransform (), "VendorID" ),
338+ PartitionField (2 , 1001 , DayTransform (), "tpep_pickup_day" ),
339+ PartitionField (3 , 1002 , IdentityTransform (), "new_col" ),
340+ )
327341
328342 table_transaction .commit_transaction ()
329343 assert test_catalog .table_exists (identifier )
0 commit comments