Skip to content

Add method and property around sequence-numbers #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyiceberg/table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ def location(self) -> str:
"""Return the table's base location."""
return self.metadata.location

@property
def last_sequence_number(self) -> int:
return self.metadata.last_sequence_number

def next_sequence_number(self) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: In Java, this is on TableMetadata, which is an internal class and not part of the public API. I don't think anyone would call this externally, but if they did it may not be accurate because the sequence number could be reassigned for a new snapshot if the commit needs to be retried. I'd probably make this _next_sequence_number() to avoid that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I'll add this to #23

return INITIAL_SEQUENCE_NUMBER if self.format_version == 1 else self.last_sequence_number + 1

def new_snapshot_id(self) -> int:
"""Generate a new snapshot-id that's not in use."""
snapshot_id = _generate_snapshot_id()
Expand Down