@@ -649,20 +649,23 @@ Status MergingSnapshotUpdate::AddManifest(ManifestFile manifest) {
649649 appended_manifests_summary_.AddedManifest (manifest);
650650 append_manifests_.push_back (std::move (manifest));
651651 } else {
652- ICEBERG_ASSIGN_OR_RAISE (auto copied, CopyManifest (manifest));
652+ ICEBERG_ASSIGN_OR_RAISE (auto copied, CopyManifest (manifest, /* update_summary=*/ true ));
653+ append_manifests_to_copy_.push_back (std::move (manifest));
653654 rewritten_append_manifests_.push_back (std::move (copied));
654655 }
655656 return {};
656657}
657658
658- Result<ManifestFile> MergingSnapshotUpdate::CopyManifest (const ManifestFile& manifest) {
659+ Result<ManifestFile> MergingSnapshotUpdate::CopyManifest (const ManifestFile& manifest,
660+ bool update_summary) {
659661 const TableMetadata& current = base ();
660662 ICEBERG_ASSIGN_OR_RAISE (auto schema, SnapshotUtil::SchemaFor (current, target_branch ()));
661663 ICEBERG_ASSIGN_OR_RAISE (auto spec,
662664 current.PartitionSpecById (manifest.partition_spec_id ));
663665 std::string path = ManifestPath ();
664666 return CopyAppendManifest (manifest, ctx_->table ->io (), schema, spec, SnapshotId (), path,
665- current.format_version , &appended_manifests_summary_);
667+ current.format_version ,
668+ update_summary ? &appended_manifests_summary_ : nullptr );
666669}
667670
668671// -------------------------------------------------------------------------
@@ -890,6 +893,13 @@ Result<std::vector<ManifestFile>> MergingSnapshotUpdate::Apply(
890893
891894 // Step 4: Write (or retrieve cached) new data manifests.
892895 ICEBERG_ASSIGN_OR_RAISE (auto written_data_manifests, WriteNewDataManifests ());
896+ if (rewritten_append_manifests_.empty () && !append_manifests_to_copy_.empty ()) {
897+ for (const auto & manifest : append_manifests_to_copy_) {
898+ ICEBERG_ASSIGN_OR_RAISE (auto copied, CopyManifest (manifest,
899+ /* update_summary=*/ false ));
900+ rewritten_append_manifests_.push_back (std::move (copied));
901+ }
902+ }
893903
894904 // Incorporate append manifests (from AddManifest), stamping each with the
895905 // current snapshot ID. append_manifests_ are used directly (inherit path);
@@ -972,7 +982,7 @@ Status MergingSnapshotUpdate::CleanUncommittedAppends(
972982 DeleteUncommitted (cached_new_delete_manifests_, committed, /* clear=*/ true ));
973983 // rewritten_append_manifests_ are always owned by the table.
974984 ICEBERG_RETURN_UNEXPECTED (
975- DeleteUncommitted (rewritten_append_manifests_, committed, /* clear=*/ false ));
985+ DeleteUncommitted (rewritten_append_manifests_, committed, /* clear=*/ true ));
976986
977987 // append_manifests_ are only owned by the table if the commit succeeded.
978988 if (!committed.empty ()) {
0 commit comments