Skip to content

fix(spec): clean up -1 snapshot ID sentinel usage and add deserialization test#2294

Merged
blackmwk merged 1 commit intoapache:mainfrom
geserdugarov:fix-snapshot-id
Mar 31, 2026
Merged

fix(spec): clean up -1 snapshot ID sentinel usage and add deserialization test#2294
blackmwk merged 1 commit intoapache:mainfrom
geserdugarov:fix-snapshot-id

Conversation

@geserdugarov
Copy link
Copy Markdown
Contributor

@geserdugarov geserdugarov commented Mar 30, 2026

Which issue does this PR close?

What changes are included in this PR?

  • Replaces hardcoded -1 with EMPTY_SNAPSHOT_ID constant in table metadata deserialization.
  • Adds test_empty_snapshot_id_is_normalized_to_none to verify that the Java-style -1 sentinel for current-snapshot-id is normalized to None during deserialization.
  • Removes the public UNASSIGNED_SNAPSHOT_ID constant and moving it to a private constant scoped to the manifest writer module.

Are these changes tested?

Adds a test test_empty_snapshot_id_is_normalized_to_none verifying the deserialization normalization.

Copy link
Copy Markdown
Contributor

@blackmwk blackmwk left a comment

Choose a reason for hiding this comment

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

Thanks @geserdugarov for this pr, there is one mistake to fix, others LGTM

pub struct ManifestWriterBuilder {
output: OutputFile,
snapshot_id: Option<i64>,
snapshot_id: i64,
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.

This is incorrect. Manifest file's snapshot id could be empty, and in this case it's inherited.

Copy link
Copy Markdown
Contributor Author

@geserdugarov geserdugarov Mar 30, 2026

Choose a reason for hiding this comment

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

Thanks for review, @blackmwk
My bad. I've reverted these changes. But I have to change commit message, so force pushed to 88a1546

output: OutputFile,

snapshot_id: Option<i64>,
snapshot_id: i64,
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.

Ditto.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@geserdugarov geserdugarov changed the title fix(spec): eliminate -1 snapshot ID sentinel from manifest write path fix(spec): clean up -1 snapshot ID sentinel usage and add deserialization test Mar 30, 2026
Copy link
Copy Markdown
Contributor

@blackmwk blackmwk left a comment

Choose a reason for hiding this comment

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

Thanks @geserdugarov for this fix!

@blackmwk blackmwk merged commit 14f2e14 into apache:main Mar 31, 2026
19 checks passed
@geserdugarov geserdugarov deleted the fix-snapshot-id branch March 31, 2026 12:48
toutane pushed a commit to DataDog/iceberg-rust that referenced this pull request Apr 30, 2026
…tion test (apache#2294)

## Which issue does this PR close?

- Closes apache#352.

## What changes are included in this PR?

- Replaces hardcoded `-1` with `EMPTY_SNAPSHOT_ID` constant in table
metadata deserialization.
- Adds `test_empty_snapshot_id_is_normalized_to_none` to verify that the
Java-style `-1` sentinel for `current-snapshot-id` is normalized to
`None` during deserialization.
- Removes the public `UNASSIGNED_SNAPSHOT_ID` constant and moving it to
a private constant scoped to the manifest writer module.

## Are these changes tested?

Adds a test `test_empty_snapshot_id_is_normalized_to_none` verifying the
deserialization normalization.

(cherry picked from commit 14f2e14)
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.

Empty snapshot ID should be Null instead of -1

2 participants