@@ -228,6 +228,8 @@ def _summary(self, snapshot_properties: dict[str, str] = EMPTY_DICT) -> Summary:
228228
229229 # avoid copying metadata for each data file
230230 table_metadata = self ._transaction .table_metadata
231+ schema = table_metadata .schema ()
232+ default_spec = table_metadata .spec ()
231233
232234 partition_summary_limit = int (
233235 table_metadata .properties .get (
@@ -239,8 +241,8 @@ def _summary(self, snapshot_properties: dict[str, str] = EMPTY_DICT) -> Summary:
239241 for data_file in self ._added_data_files :
240242 ssc .add_file (
241243 data_file = data_file ,
242- partition_spec = table_metadata . spec () ,
243- schema = table_metadata . schema () ,
244+ partition_spec = default_spec ,
245+ schema = schema ,
244246 )
245247
246248 if len (self ._deleted_data_files ) > 0 :
@@ -249,7 +251,7 @@ def _summary(self, snapshot_properties: dict[str, str] = EMPTY_DICT) -> Summary:
249251 ssc .remove_file (
250252 data_file = data_file ,
251253 partition_spec = specs [data_file .spec_id ],
252- schema = table_metadata . schema () ,
254+ schema = schema ,
253255 )
254256
255257 previous_snapshot = (
@@ -424,12 +426,14 @@ def _copy_with_new_status(entry: ManifestEntry, status: ManifestEntryStatus) ->
424426 data_file = entry .data_file ,
425427 )
426428
429+ # avoid copying metadata for each evaluator
430+ table_metadata = self ._transaction .table_metadata
431+ schema = table_metadata .schema ()
432+
427433 manifest_evaluators : dict [int , Callable [[ManifestFile ], bool ]] = KeyDefaultDict (self ._build_manifest_evaluator )
428- strict_metrics_evaluator = _StrictMetricsEvaluator (
429- self .schema (), self ._predicate , case_sensitive = self ._case_sensitive
430- ).eval
434+ strict_metrics_evaluator = _StrictMetricsEvaluator (schema , self ._predicate , case_sensitive = self ._case_sensitive ).eval
431435 inclusive_metrics_evaluator = _InclusiveMetricsEvaluator (
432- self . schema () , self ._predicate , case_sensitive = self ._case_sensitive
436+ schema , self ._predicate , case_sensitive = self ._case_sensitive
433437 ).eval
434438
435439 existing_manifests = []
@@ -441,7 +445,7 @@ def _copy_with_new_status(entry: ManifestEntry, status: ManifestEntryStatus) ->
441445 # Should be the current tip of the _target_branch
442446 parent_snapshot_id_for_delete_source = self ._parent_snapshot_id
443447 if parent_snapshot_id_for_delete_source is not None :
444- snapshot = self . _transaction . table_metadata .snapshot_by_id (parent_snapshot_id_for_delete_source )
448+ snapshot = table_metadata .snapshot_by_id (parent_snapshot_id_for_delete_source )
445449 if snapshot : # Ensure snapshot is found
446450 for manifest_file in snapshot .manifests (io = self ._io ):
447451 if manifest_file .content == ManifestContent .DATA :
@@ -542,18 +546,19 @@ def __init__(
542546 from pyiceberg .table import TableProperties
543547
544548 super ().__init__ (operation , transaction , io , commit_uuid , snapshot_properties , branch )
549+ table_properties = self ._transaction .table_metadata .properties
545550 self ._target_size_bytes = property_as_int (
546- self . _transaction . table_metadata . properties ,
551+ table_properties ,
547552 TableProperties .MANIFEST_TARGET_SIZE_BYTES ,
548553 TableProperties .MANIFEST_TARGET_SIZE_BYTES_DEFAULT ,
549554 ) # type: ignore
550555 self ._min_count_to_merge = property_as_int (
551- self . _transaction . table_metadata . properties ,
556+ table_properties ,
552557 TableProperties .MANIFEST_MIN_MERGE_COUNT ,
553558 TableProperties .MANIFEST_MIN_MERGE_COUNT_DEFAULT ,
554559 ) # type: ignore
555560 self ._merge_enabled = property_as_bool (
556- self . _transaction . table_metadata . properties ,
561+ table_properties ,
557562 TableProperties .MANIFEST_MERGE_ENABLED ,
558563 TableProperties .MANIFEST_MERGE_ENABLED_DEFAULT ,
559564 )
0 commit comments