@@ -984,9 +984,10 @@ def _(update: AddSchemaUpdate, base_metadata: TableMetadata, context: _TableMeta
984
984
if update .last_column_id < base_metadata .last_column_id :
985
985
raise ValueError (f"Invalid last column id { update .last_column_id } , must be >= { base_metadata .last_column_id } " )
986
986
987
+ skip_empty_schema = base_metadata .schemas == [Schema ()]
987
988
metadata_updates : Dict [str , Any ] = {
988
989
"last_column_id" : update .last_column_id ,
989
- "schemas" : base_metadata .schemas + [update .schema_ ],
990
+ "schemas" : [ update . schema_ ] if skip_empty_schema else base_metadata .schemas + [update .schema_ ],
990
991
}
991
992
992
993
context .add_update (update )
@@ -1127,9 +1128,20 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
1127
1128
return base_metadata .model_copy (update = metadata_updates )
1128
1129
1129
1130
1131
+ @_apply_table_update .register (RemoveSnapshotRefUpdate )
1132
+ def _ (update : RemoveSnapshotRefUpdate , base_metadata : TableMetadata , context : _TableMetadataUpdateContext ) -> TableMetadata :
1133
+ # (TODO) actually implement this
1134
+ context .add_update (update )
1135
+ return base_metadata
1136
+
1137
+
1138
+
1130
1139
@_apply_table_update .register (AddSortOrderUpdate )
1131
1140
def _ (update : AddSortOrderUpdate , base_metadata : TableMetadata , context : _TableMetadataUpdateContext ) -> TableMetadata :
1132
1141
context .add_update (update )
1142
+ if update .sort_order == UNSORTED_SORT_ORDER :
1143
+ # no op
1144
+ return base_metadata
1133
1145
return base_metadata .model_copy (
1134
1146
update = {
1135
1147
"sort_orders" : base_metadata .sort_orders + [update .sort_order ],
0 commit comments