Skip to content

fix(table): preserve explicit snapshot ID zero in scans - #3998

Merged
Fokko merged 1 commit into
apache:mainfrom
hcrosse:fix-snapshot-zero-scan
Sep 18, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
hcrosse:fix-snapshot-zero-scan

Conversation

@hcrosse

@hcrosse hcrosse commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

An explicit snapshot_id=0 falls back to the current snapshot during local scan planning. It can also be overridden by use_ref(), unlike other explicit snapshot IDs. Distinguish zero from None in 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 lint pass 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.

Distinguish snapshot ID zero from an omitted ID when selecting a scan snapshot and rejecting ref overrides.
Copilot AI lite review requested due to automatic review settings September 18, 2026 12:58
@hcrosse
hcrosse marked this pull request as draft September 18, 2026 13:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 0 from None.
  • 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
hcrosse marked this pull request as ready for review September 18, 2026 13:03

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great one @hcrosse Thanks!

@Fokko
Fokko added this pull request to the merge queue Sep 18, 2026
Merged via the queue into apache:main with commit 7e7d340 Sep 18, 2026
21 checks passed
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.

3 participants