From 28822275ed394f4be11dd1e5b1c58f1e325590ef Mon Sep 17 00:00:00 2001 From: shiwk Date: Wed, 11 Feb 2026 23:13:48 +0800 Subject: [PATCH] fix: add Field alias for SetPartitionStatisticsUpdate.partition_statistics --- pyiceberg/table/update/__init__.py | 2 +- tests/table/test_init.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyiceberg/table/update/__init__.py b/pyiceberg/table/update/__init__.py index 455b46953c..e892b838c9 100644 --- a/pyiceberg/table/update/__init__.py +++ b/pyiceberg/table/update/__init__.py @@ -212,7 +212,7 @@ class RemoveSchemasUpdate(IcebergBaseModel): class SetPartitionStatisticsUpdate(IcebergBaseModel): action: Literal["set-partition-statistics"] = Field(default="set-partition-statistics") - partition_statistics: PartitionStatisticsFile + partition_statistics: PartitionStatisticsFile = Field(alias="partition-statistics") class RemovePartitionStatisticsUpdate(IcebergBaseModel): diff --git a/tests/table/test_init.py b/tests/table/test_init.py index aef6e3cc5f..30c4a3a45a 100644 --- a/tests/table/test_init.py +++ b/tests/table/test_init.py @@ -1605,6 +1605,10 @@ def test_set_partition_statistics_update(table_v2_with_statistics: Table) -> Non partition_statistics=partition_statistics_file, ) + # Verify that serialization uses 'partition-statistics' alias + dumped_with_alias = update.model_dump(by_alias=True) + assert "partition-statistics" in dumped_with_alias + new_metadata = update_table_metadata( table_v2_with_statistics.metadata, (update,),