Skip to content

Commit 209329b

Browse files
committed
combine helper func
1 parent 8d31af0 commit 209329b

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

pyiceberg/table/statistics.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,7 @@ class PartitionStatisticsFile(StatisticsCommonFields):
4848

4949

5050
def filter_statistics_by_snapshot_id(
51-
statistics: List[StatisticsFile],
51+
statistics: List[StatisticsFile | PartitionStatisticsFile],
5252
reject_snapshot_id: int,
53-
) -> List[StatisticsFile]:
54-
return [stat for stat in statistics if stat.snapshot_id != reject_snapshot_id]
55-
56-
57-
def filter_partition_statistics_by_snapshot_id(
58-
statistics: List[PartitionStatisticsFile],
59-
reject_snapshot_id: int,
60-
) -> List[PartitionStatisticsFile]:
53+
) -> List[StatisticsFile | PartitionStatisticsFile]:
6154
return [stat for stat in statistics if stat.snapshot_id != reject_snapshot_id]

pyiceberg/table/update/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from pyiceberg.table.statistics import (
4040
PartitionStatisticsFile,
4141
StatisticsFile,
42-
filter_partition_statistics_by_snapshot_id,
4342
filter_statistics_by_snapshot_id,
4443
)
4544
from pyiceberg.typedef import (
@@ -601,7 +600,7 @@ def _(update: RemoveStatisticsUpdate, base_metadata: TableMetadata, context: _Ta
601600

602601
@_apply_table_update.register(SetPartitionStatisticsUpdate)
603602
def _(update: SetPartitionStatisticsUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
604-
partition_statistics = filter_partition_statistics_by_snapshot_id(
603+
partition_statistics = filter_statistics_by_snapshot_id(
605604
base_metadata.partition_statistics, update.partition_statistics.snapshot_id
606605
)
607606
context.add_update(update)
@@ -616,7 +615,7 @@ def _(
616615
if not any(part_stat.snapshot_id == update.snapshot_id for part_stat in base_metadata.partition_statistics):
617616
raise ValueError(f"Partition Statistics with snapshot id {update.snapshot_id} does not exist")
618617

619-
statistics = filter_partition_statistics_by_snapshot_id(base_metadata.partition_statistics, update.snapshot_id)
618+
statistics = filter_statistics_by_snapshot_id(base_metadata.partition_statistics, update.snapshot_id)
620619
context.add_update(update)
621620

622621
return base_metadata.model_copy(update={"partition_statistics": statistics})

0 commit comments

Comments
 (0)