112
112
update_table_metadata ,
113
113
)
114
114
from pyiceberg .table .update .schema import UpdateSchema
115
- from pyiceberg .table .update .snapshot import ManageSnapshots , UpdateSnapshot , _FastAppendFiles
115
+ from pyiceberg .table .update .snapshot import ManageSnapshots , RewriteManifestsResult , UpdateSnapshot , _FastAppendFiles
116
116
from pyiceberg .table .update .spec import UpdateSpec
117
117
from pyiceberg .table .update .statistics import UpdateStatistics
118
118
from pyiceberg .transforms import IdentityTransform
@@ -420,9 +420,12 @@ def update_snapshot(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> U
420
420
"""
421
421
return UpdateSnapshot (self , io = self ._table .io , snapshot_properties = snapshot_properties )
422
422
423
- def rewrite_manifests (self , spec_id : Optional [int ] = None ) -> None :
423
+ def rewrite_manifests (self , spec_id : Optional [int ] = None ) -> RewriteManifestsResult :
424
+ if self ._table .current_snapshot () is None :
425
+ return RewriteManifestsResult (rewritten_manifests = [], added_manifests = [])
424
426
with self .update_snapshot ().rewrite () as rewrite :
425
- rewrite .rewrite_manifests ()
427
+ rewritten = rewrite .rewrite_manifests ()
428
+ return rewritten
426
429
427
430
def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT ) -> None :
428
431
"""
@@ -1174,7 +1177,7 @@ def add_files(
1174
1177
def rewrite_manifests (
1175
1178
self ,
1176
1179
spec_id : Optional [int ] = None ,
1177
- ) -> None :
1180
+ ) -> RewriteManifestsResult :
1178
1181
"""
1179
1182
Shorthand API for Rewriting manifests for the table.
1180
1183
@@ -1183,7 +1186,7 @@ def rewrite_manifests(
1183
1186
1184
1187
"""
1185
1188
with self .transaction () as tx :
1186
- tx .rewrite_manifests (spec_id = spec_id )
1189
+ return tx .rewrite_manifests (spec_id = spec_id )
1187
1190
1188
1191
def update_spec (self , case_sensitive : bool = True ) -> UpdateSpec :
1189
1192
return UpdateSpec (Transaction (self , autocommit = True ), case_sensitive = case_sensitive )
0 commit comments