@@ -721,22 +721,22 @@ def _initial_changes(self, table_metadata: TableMetadata) -> None:
721721
722722 schema : Schema = table_metadata .schema ()
723723 self ._updates += (
724- AddSchemaUpdate (schema_ = schema , last_column_id = schema .highest_field_id , initial_change = True ),
724+ AddSchemaUpdate (schema_ = schema , last_column_id = schema .highest_field_id ),
725725 SetCurrentSchemaUpdate (schema_id = - 1 ),
726726 )
727727
728728 spec : PartitionSpec = table_metadata .spec ()
729729 if spec .is_unpartitioned ():
730- self ._updates += (AddPartitionSpecUpdate (spec = UNPARTITIONED_PARTITION_SPEC , initial_change = True ),)
730+ self ._updates += (AddPartitionSpecUpdate (spec = UNPARTITIONED_PARTITION_SPEC ),)
731731 else :
732- self ._updates += (AddPartitionSpecUpdate (spec = spec , initial_change = True ),)
732+ self ._updates += (AddPartitionSpecUpdate (spec = spec ),)
733733 self ._updates += (SetDefaultSpecUpdate (spec_id = - 1 ),)
734734
735735 sort_order : Optional [SortOrder ] = table_metadata .sort_order_by_id (table_metadata .default_sort_order_id )
736736 if sort_order is None or sort_order .is_unsorted :
737- self ._updates += (AddSortOrderUpdate (sort_order = UNSORTED_SORT_ORDER , initial_change = True ),)
737+ self ._updates += (AddSortOrderUpdate (sort_order = UNSORTED_SORT_ORDER ),)
738738 else :
739- self ._updates += (AddSortOrderUpdate (sort_order = sort_order , initial_change = True ),)
739+ self ._updates += (AddSortOrderUpdate (sort_order = sort_order ),)
740740 self ._updates += (SetDefaultSortOrderUpdate (sort_order_id = - 1 ),)
741741
742742 self ._updates += (
@@ -779,8 +779,6 @@ class AddSchemaUpdate(IcebergBaseModel):
779779 # This field is required: https://github.com/apache/iceberg/pull/7445
780780 last_column_id : int = Field (alias = "last-column-id" )
781781
782- initial_change : bool = Field (default = False , exclude = True )
783-
784782
785783class SetCurrentSchemaUpdate (IcebergBaseModel ):
786784 action : Literal ["set-current-schema" ] = Field (default = "set-current-schema" )
@@ -793,8 +791,6 @@ class AddPartitionSpecUpdate(IcebergBaseModel):
793791 action : Literal ["add-spec" ] = Field (default = "add-spec" )
794792 spec : PartitionSpec
795793
796- initial_change : bool = Field (default = False , exclude = True )
797-
798794
799795class SetDefaultSpecUpdate (IcebergBaseModel ):
800796 action : Literal ["set-default-spec" ] = Field (default = "set-default-spec" )
@@ -807,8 +803,6 @@ class AddSortOrderUpdate(IcebergBaseModel):
807803 action : Literal ["add-sort-order" ] = Field (default = "add-sort-order" )
808804 sort_order : SortOrder = Field (alias = "sort-order" )
809805
810- initial_change : bool = Field (default = False , exclude = True )
811-
812806
813807class SetDefaultSortOrderUpdate (IcebergBaseModel ):
814808 action : Literal ["set-default-sort-order" ] = Field (default = "set-default-sort-order" )
@@ -992,7 +986,7 @@ def _(update: AddSchemaUpdate, base_metadata: TableMetadata, context: _TableMeta
992986
993987 metadata_updates : Dict [str , Any ] = {
994988 "last_column_id" : update .last_column_id ,
995- "schemas" : [ update . schema_ ] if update . initial_change else base_metadata .schemas + [update .schema_ ],
989+ "schemas" : base_metadata .schemas + [update .schema_ ],
996990 }
997991
998992 context .add_update (update )
@@ -1022,11 +1016,11 @@ def _(update: SetCurrentSchemaUpdate, base_metadata: TableMetadata, context: _Ta
10221016@_apply_table_update .register (AddPartitionSpecUpdate )
10231017def _ (update : AddPartitionSpecUpdate , base_metadata : TableMetadata , context : _TableMetadataUpdateContext ) -> TableMetadata :
10241018 for spec in base_metadata .partition_specs :
1025- if spec .spec_id == update .spec .spec_id and not update . initial_change :
1019+ if spec .spec_id == update .spec .spec_id :
10261020 raise ValueError (f"Partition spec with id { spec .spec_id } already exists: { spec } " )
10271021
10281022 metadata_updates : Dict [str , Any ] = {
1029- "partition_specs" : [ update . spec ] if update . initial_change else base_metadata .partition_specs + [update .spec ],
1023+ "partition_specs" : base_metadata .partition_specs + [update .spec ],
10301024 "last_partition_id" : max (
10311025 max ([field .field_id for field in update .spec .fields ], default = 0 ),
10321026 base_metadata .last_partition_id or PARTITION_FIELD_ID_START - 1 ,
@@ -1134,7 +1128,7 @@ def _(update: AddSortOrderUpdate, base_metadata: TableMetadata, context: _TableM
11341128 context .add_update (update )
11351129 return base_metadata .model_copy (
11361130 update = {
1137- "sort_orders" : [ update . sort_order ] if update . initial_change else base_metadata .sort_orders + [update .sort_order ],
1131+ "sort_orders" : base_metadata .sort_orders + [update .sort_order ],
11381132 }
11391133 )
11401134
0 commit comments