fix(table): preserve explicit snapshot ID zero in scans - #3998
Merged
Merged
Conversation
Distinguish snapshot ID zero from an omitted ID when selecting a scan snapshot and rejecting ref overrides.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues were identified.
Pull request overview
Fixes table scans so explicit snapshot ID 0 is preserved instead of treated as unset.
Changes:
- Distinguishes snapshot ID
0fromNone. - Prevents
use_ref()from overriding explicit snapshot selections. - Adds regression tests for zero, missing, default, and nonzero snapshots.
File summaries
| File | Description |
|---|---|
tests/table/test_init.py |
Adds regression coverage for zero-ID scans and ref behavior. |
pyiceberg/table/__init__.py |
Preserves explicit zero snapshot IDs and rejects ref overrides. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hcrosse
marked this pull request as ready for review
September 18, 2026 13:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
An explicit
snapshot_id=0falls back to the current snapshot during local scan planning. It can also be overridden byuse_ref(), unlike other explicit snapshot IDs. Distinguish zero fromNonein both checks.This follows the earlier zero-ID fix in #249 (related issue #232), which covered
Table.current_snapshot()but not these scan paths.Are these changes tested?
Added regression tests for zero-ID selection, a missing zero-ID snapshot, and ref override rejection, with default and nonzero controls. The zero-ID cases fail before the fix and pass afterward. The full unit suite and
make lintpass on Python 3.12.Are there any user-facing changes?
Scans explicitly selecting snapshot zero now resolve that snapshot rather than the current snapshot.
use_ref()rejects overriding that explicit selection, consistently with nonzero snapshot IDs.