@@ -340,23 +340,6 @@ def set_properties(self, properties: Properties = EMPTY_DICT, **kwargs: Any) ->
340
340
updates = properties or kwargs
341
341
return self ._apply ((SetPropertiesUpdate (updates = updates ),))
342
342
343
- def rollback_to_snapshot (self , snapshot_id : int ) -> Transaction :
344
- if self .table_metadata .snapshot_by_id (snapshot_id ) is None :
345
- raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
346
- if snapshot_id not in [ancestor .ancestor_id for ancestor in self .current_ancestors ()]:
347
- raise ValidationError (f"Cannot roll back to snapshot, not an ancestor of the current state: { snapshot_id } " )
348
- return self .set_ref_snapshot (snapshot_id = snapshot_id , ref_name = "main" , type = "branch" )
349
-
350
- def rollback_to_timestamp (self , timestamp : int ) -> Transaction :
351
- if (snapshot := self .latest_snapshot_before_timestamp (timestamp )) is None :
352
- raise ValidationError (f"Cannot roll back, no valid snapshot older than: { timestamp } " )
353
- return self .set_ref_snapshot (snapshot_id = snapshot .snapshot_id , ref_name = "main" , type = "branch" )
354
-
355
- def set_current_snapshot (self , snapshot_id : int ) -> None :
356
- if self .table_metadata .snapshot_by_id (snapshot_id ) is None :
357
- raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
358
- return self .set_ref_snapshot (snapshot_id = snapshot_id , ref_name = "main" , type = "branch" )
359
-
360
343
def update_schema (self , allow_incompatible_changes : bool = False , case_sensitive : bool = True ) -> UpdateSchema :
361
344
"""Create a new UpdateSchema to alter the columns of this table.
362
345
@@ -1307,6 +1290,23 @@ def snapshot_by_name(self, name: str) -> Optional[Snapshot]:
1307
1290
return self .snapshot_by_id (ref .snapshot_id )
1308
1291
return None
1309
1292
1293
+ def rollback_to_snapshot (self , snapshot_id : int ) -> Transaction :
1294
+ if self .snapshot_by_id (snapshot_id ) is None :
1295
+ raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
1296
+ if snapshot_id not in [ancestor .ancestor_id for ancestor in self .current_ancestors ()]:
1297
+ raise ValidationError (f"Cannot roll back to snapshot, not an ancestor of the current state: { snapshot_id } " )
1298
+ return self .set_ref_snapshot (snapshot_id = snapshot_id , parent_snapshot_id = self .current_snapshot ().snapshot_id , ref_name = "main" , type = "branch" )
1299
+
1300
+ def rollback_to_timestamp (self , timestamp : int ) -> Transaction :
1301
+ if (snapshot := self .latest_snapshot_before_timestamp (timestamp )) is None :
1302
+ raise ValidationError (f"Cannot roll back, no valid snapshot older than: { timestamp } " )
1303
+ return self .set_ref_snapshot (snapshot_id = snapshot .snapshot_id , parent_snapshot_id = self .current_snapshot ().snapshot_id , ref_name = "main" , type = "branch" )
1304
+
1305
+ def set_current_snapshot (self , snapshot_id : int ) -> Transaction :
1306
+ if self .snapshot_by_id (snapshot_id ) is None :
1307
+ raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
1308
+ return self .set_ref_snapshot (snapshot_id = snapshot_id , parent_snapshot_id = self .current_snapshot ().snapshot_id , ref_name = "main" , type = "branch" )
1309
+
1310
1310
def history (self ) -> List [SnapshotLogEntry ]:
1311
1311
"""Get the snapshot history of this table."""
1312
1312
return self .metadata .snapshot_log
0 commit comments