ShivamSharma43 opened a new pull request, #4470:
URL: https://github.com/apache/iceberg-python/pull/4470

   # Rationale for this change
   
   A commit that sets `main` more than once adds every one of those snapshots 
to the snapshot log. `Table.overwrite` does this when it commits a delete and 
an append together, so time travel can resolve to the delete snapshot, which 
was never the committed state of the table:
   
   ```python
   table.append(pa.table({"x": [1]}))
   table.overwrite(pa.table({"x": [2]}))
   
   _, delete, _ = table.snapshots()
   snapshot = table.snapshot_as_of_timestamp(delete.timestamp_ms)
   table.scan(snapshot_id=snapshot.snapshot_id).to_arrow()  # no rows, expected 
x = 1
   ```
   
   This happens in catalogs where PyIceberg applies the updates itself. Java's 
`TableMetadata.Builder` suppresses these entries (`intermediateSnapshotIdSet` 
and `updateSnapshotLog`). This change does the same: snapshots that are added 
and set as `main`, but are not current once all updates are applied, are 
removed from the log. They stay in `snapshots`.
   
   ## Are these changes tested?
   
   Yes, with a unit test on `update_table_metadata` and a test that overwrites 
a table in the memory and SQL catalogs. Both fail without the fix.
   
   ## Are there any user-facing changes?
   
   Yes. `Table.history()` and `inspect.history()` have one entry for a commit 
that replaces its own snapshots, and `snapshot_as_of_timestamp` no longer 
returns the replaced ones. Tables that already have such entries in their log 
are not rewritten.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to