This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch sm/read-partition-statistics
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git

commit 591b95499e5bda70cd98cb75bc7589b561352900
Author: Fokko <[email protected]>
AuthorDate: Tue Jun 24 11:28:24 2025 +0200

    Add a test
---
 pyiceberg/table/statistics.py  |  4 ++--
 tests/table/test_metadata.py   |  4 ++--
 tests/table/test_statistics.py | 30 ++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/pyiceberg/table/statistics.py b/pyiceberg/table/statistics.py
index 702a2620..a2e1b149 100644
--- a/pyiceberg/table/statistics.py
+++ b/pyiceberg/table/statistics.py
@@ -37,13 +37,13 @@ class StatisticsCommonFields(IcebergBaseModel):
     file_size_in_bytes: int = Field(alias="file-size-in-bytes")
 
 
-class StatisticsFile(StatisticsCommonFields, IcebergBaseModel):
+class StatisticsFile(StatisticsCommonFields):
     file_footer_size_in_bytes: int = Field(alias="file-footer-size-in-bytes")
     key_metadata: Optional[str] = Field(alias="key-metadata", default=None)
     blob_metadata: List[BlobMetadata] = Field(alias="blob-metadata")
 
 
-class PartitionStatisticsFile(IcebergBaseModel):
+class PartitionStatisticsFile(StatisticsCommonFields):
     pass
 
 
diff --git a/tests/table/test_metadata.py b/tests/table/test_metadata.py
index a8410cff..27fd00bd 100644
--- a/tests/table/test_metadata.py
+++ b/tests/table/test_metadata.py
@@ -173,13 +173,13 @@ def test_updating_metadata(example_table_metadata_v2: 
Dict[str, Any]) -> None:
 def test_serialize_v1(example_table_metadata_v1: Dict[str, Any]) -> None:
     table_metadata = TableMetadataV1(**example_table_metadata_v1)
     table_metadata_json = table_metadata.model_dump_json()
-    expected = 
"""{"location":"s3://bucket/test/location","table-uuid":"d20125c8-7284-442c-9aea-15fee620737c","last-updated-ms":1602638573874,"last-column-id":3,"schemas":[{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},{"id":3,"name":"z","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]}],"current-schema-id":0,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"fiel
 [...]
+    expected = 
"""{"location":"s3://bucket/test/location","table-uuid":"d20125c8-7284-442c-9aea-15fee620737c","last-updated-ms":1602638573874,"last-column-id":3,"schemas":[{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},{"id":3,"name":"z","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]}],"current-schema-id":0,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"fiel
 [...]
     assert table_metadata_json == expected
 
 
 def test_serialize_v2(example_table_metadata_v2: Dict[str, Any]) -> None:
     table_metadata = 
TableMetadataV2(**example_table_metadata_v2).model_dump_json()
-    expected = 
"""{"location":"s3://bucket/test/location","table-uuid":"9c12d441-03fe-4693-9a96-a0705ddf69c1","last-updated-ms":1602638573590,"last-column-id":3,"schemas":[{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]},{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},{"id":3,"name":"z","type":"long","required":true}],"schema
 [...]
+    expected = 
"""{"location":"s3://bucket/test/location","table-uuid":"9c12d441-03fe-4693-9a96-a0705ddf69c1","last-updated-ms":1602638573590,"last-column-id":3,"schemas":[{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]},{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},{"id":3,"name":"z","type":"long","required":true}],"schema
 [...]
     assert table_metadata == expected
 
 
diff --git a/tests/table/test_statistics.py b/tests/table/test_statistics.py
new file mode 100644
index 00000000..a7f1b10b
--- /dev/null
+++ b/tests/table/test_statistics.py
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from pyiceberg.table.statistics import PartitionStatisticsFile
+
+
+def test_partition_statistics_file() -> None:
+    partition_statistics_file_json = (
+        
"""{"snapshot-id":123,"statistics-path":"s3://bucket/statistics.parquet","file-size-in-bytes":345}"""
+    )
+    partition_statistics_file = 
PartitionStatisticsFile.model_validate_json(partition_statistics_file_json)
+
+    assert partition_statistics_file == PartitionStatisticsFile(
+        snapshot_id=123, statistics_path="s3://bucket/statistics.parquet", 
file_size_in_bytes=345
+    )
+
+    assert partition_statistics_file.model_dump_json() == 
partition_statistics_file_json

Reply via email to