diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py index cab5d73d27..7e4669bbed 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -438,6 +438,15 @@ def update_snapshot(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> U """ return UpdateSnapshot(self, io=self._table.io, snapshot_properties=snapshot_properties) + def update_statistics(self) -> UpdateStatistics: + """ + Create a new UpdateStatistics to update the statistics of the table. + + Returns: + A new UpdateStatistics + """ + return UpdateStatistics(transaction=self) + def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> None: """ Shorthand API for appending a PyArrow table to a table transaction. diff --git a/tests/integration/test_statistics_operations.py b/tests/integration/test_statistics_operations.py index a7b4e38802..09273768d9 100644 --- a/tests/integration/test_statistics_operations.py +++ b/tests/integration/test_statistics_operations.py @@ -82,3 +82,10 @@ def create_statistics_file(snapshot_id: int, type_name: str) -> StatisticsFile: update.remove_statistics(add_snapshot_id_1) assert len(tbl.metadata.statistics) == 1 + + with tbl.transaction() as txn: + with txn.update_statistics() as update: + update.set_statistics(statistics_file_snap_1) + update.set_statistics(statistics_file_snap_2) + + assert len(tbl.metadata.statistics) == 2