Skip to content

Commit b9c912d

Browse files
committed
Remove statistics
1 parent 9e3f7c7 commit b9c912d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pyiceberg/table/update/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19+
import itertools
1920
import uuid
2021
from abc import ABC, abstractmethod
2122
from datetime import datetime
@@ -474,9 +475,15 @@ def _(update: RemoveSnapshotsUpdate, base_metadata: TableMetadata, context: _Tab
474475
for ref_name, ref in base_metadata.refs.items()
475476
if ref.snapshot_id in update.snapshot_ids
476477
)
478+
remove_statistics_updates = (
479+
RemoveStatisticsUpdate(statistics_file.snapshot_id)
480+
for statistics_file in base_metadata.statistics
481+
if statistics_file.snapshot_id in update.snapshot_ids
482+
)
483+
updates = itertools.chain(remove_ref_updates, remove_statistics_updates)
477484
new_metadata = base_metadata
478-
for remove_ref in remove_ref_updates:
479-
new_metadata = _apply_table_update(remove_ref, new_metadata, context)
485+
for update in updates:
486+
new_metadata = _apply_table_update(update, new_metadata, context)
480487

481488
context.add_update(update)
482489
return new_metadata.model_copy(update={"snapshots": snapshots})

0 commit comments

Comments
 (0)