diff --git a/pyiceberg/table/inspect.py b/pyiceberg/table/inspect.py index 5cae743313..9d7449df38 100644 --- a/pyiceberg/table/inspect.py +++ b/pyiceberg/table/inspect.py @@ -92,7 +92,7 @@ def snapshots(self) -> pa.Table: "committed_at": datetime.fromtimestamp(snapshot.timestamp_ms / 1000.0, tz=timezone.utc), "snapshot_id": snapshot.snapshot_id, "parent_id": snapshot.parent_snapshot_id, - "operation": str(operation), + "operation": operation, "manifest_list": snapshot.manifest_list, "summary": additional_properties, } diff --git a/tests/table/test_inspect.py b/tests/table/test_inspect.py index c325af2033..ab6a905a04 100644 --- a/tests/table/test_inspect.py +++ b/tests/table/test_inspect.py @@ -68,3 +68,15 @@ def test_inspect_entries_and_files_render_null_bound(catalog: InMemoryCatalog) - files_metrics = tbl.inspect.files().to_pydict()["readable_metrics"][0]["s"] assert files_metrics["lower_bound"] is None assert files_metrics["upper_bound"] is None + + +def test_inspect_snapshots_preserves_null_operation(catalog: InMemoryCatalog) -> None: + schema = Schema(NestedField(1, "s", StringType(), required=False)) + tbl = catalog.create_table("default.snapshot_without_summary", schema) + tbl.append(pa.table({"s": ["value"]}, schema=pa.schema([pa.field("s", pa.large_string(), nullable=True)]))) + + snapshots = list(tbl.metadata.snapshots) + snapshots[0] = snapshots[0].model_copy(update={"summary": None}) + tbl.metadata = tbl.metadata.model_copy(update={"snapshots": snapshots}) + + assert tbl.inspect.snapshots().to_pydict()["operation"] == [None]