-
Notifications
You must be signed in to change notification settings - Fork 425
feat: Add support for rolling back to timestamp #2879
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
base: main
Are you sure you want to change the base?
Conversation
|
Looks like Test Infra failed need to retrigger tests. |
jayceslesar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple of suggestions and the tests also look good!
| def latest_ancestor_before_timestamp(table_metadata: TableMetadata, timestamp_ms: int) -> Snapshot | None: | ||
| """Find the latest ancestor snapshot whose timestamp is before the provided timestamp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice from a users perspective to allow this to be a datetime as well? Does differ from the java impl though...
| for ancestor in ancestors_of(table_metadata.current_snapshot(), table_metadata): | ||
| if timestamp_ms > ancestor.timestamp_ms > result_timestamp: | ||
| result = ancestor | ||
| result_timestamp = ancestor.timestamp_ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about using a max(filter(...)) statement here? I think a little easier to follow than the double greater than expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe not, this does match the java
|
|
||
| return self.set_current_snapshot(snapshot_id=snapshot_id) | ||
|
|
||
| def rollback_to_timestamp(self, timestamp_ms: int) -> ManageSnapshots: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add support for datetime too.
Co-authored-by: Chinmay Bhat <12948588+chinmay-bhat@users.noreply.github.com>
Rationale for this change
This PR adds the ability to rollback a table to a ancestoral snapshot given a timestamp. Some of this work was also done in #758, and is a progress pr to be merged after #2871 & #2878. This is standalone from the other changes but it makes use of the helpers in the other prs.
Additionally, adding some more tests.
Are these changes tested?
Yes
Are there any user-facing changes?
New API for meta