Skip to content

Return null operation for snapshots without a summary - #4477

Open
rahulsmahadev wants to merge 2 commits into
apache:mainfrom
rahulsmahadev:rahul/inspect-snapshots-operation-null
Open

rahulsmahadev wants to merge 2 commits into
apache:mainfrom
rahulsmahadev:rahul/inspect-snapshots-operation-null

Conversation

@rahulsmahadev

Copy link
Copy Markdown
Contributor

Rationale for this change

Bug: a snapshot can have no summary, and then it has no operation. The summary is optional in v1, and a v1 table upgraded to v2 keeps such snapshots. Table.inspect.snapshots() then shows the text "None" as the operation:

# tbl is a format v1 table whose snapshot has no summary
tbl.inspect.snapshots().column("operation").to_pylist()
# ['None'], expected [None]

snapshots() sets operation = None in this case, then stores str(operation) in the nullable column.

Fix: store operation as is, so a missing summary gives a null cell. summary is already null.

Java: Spark's .snapshots scan uses SnapshotsTable, which returns the operation parsed by SnapshotParser unchanged, including null (TestSnapshotJson checks the null). This PR fixes the equivalent PyIceberg inspection output.

Still different from Java, not changed here: "summary": {} reads as operation overwrite (with a warning, as in Summary), while Java reads it as no summary.

Are these changes tested?

Yes. test_inspect_snapshots_operation_is_null_without_summary in tests/table/test_inspect.py builds a v1 table, removes the summary from its snapshot in the metadata file, and checks that operation is null. It fails on main with ['None'] where [None] is expected, and passes with this change. The v2 control still reports append.

Are there any user-facing changes?

Yes, operation is null instead of the string None for snapshots without a summary. Please add the changelog label.

This pull request and its description were written by Isaac.

rahulsmahadev and others added 2 commits November 23, 2026 17:18
A format v1 snapshot can have no summary, so it has no operation.
inspect.snapshots() stored str(operation), which put the text "None" in
the nullable operation column. Store the operation as is, so the cell
is null, as Java's SnapshotsTable does.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant