-
Notifications
You must be signed in to change notification settings - Fork 459
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
fix: failing test est_restore_by_datetime #2000
Changes from all commits
a8676a5
e5ab0a4
18bc6dc
cfe3db9
94b19bf
87e5f29
a8d46ee
ff6ac93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,6 +586,7 @@ impl DeltaTable { | |
|
||
debug!("merging table state with version: {new_version}"); | ||
let s = DeltaTableState::from_actions(actions, new_version)?; | ||
|
||
self.state | ||
.merge(s, self.config.require_tombstones, self.config.require_files); | ||
if self.version() == max_version { | ||
|
@@ -637,17 +638,31 @@ impl DeltaTable { | |
&mut self, | ||
version: i64, | ||
) -> Result<i64, DeltaTableError> { | ||
// Use a cached timestamp info if available | ||
match self.version_timestamp.get(&version) { | ||
Some(ts) => Ok(*ts), | ||
None => { | ||
let meta = self | ||
.object_store() | ||
.head(&commit_uri_from_version(version)) | ||
.await?; | ||
let ts = meta.last_modified.timestamp_millis(); | ||
// Load the version specified | ||
if self.version() != version { | ||
self.load_version(version).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @r3stl355 I am not as familiar with the callers of I'm honestly not sure if |
||
} | ||
let timestamp: Option<i64> = if !self.state.commit_infos().is_empty() { | ||
self.state.commit_infos().last().unwrap().timestamp | ||
Comment on lines
+649
to
+650
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a concept I've discussed with @ion-elgreco in Slack a bit. The value of the Since the protocol doesn't dictate the format here, this could be epoch, or any other random timestmap and we have no guarantees other than Delta/Spark's convention that it will actually represent the timestamp of the last written version. All that said, I like that this is a sort of guarded optimization, I'm really not sure how to make this much safer though 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we just check the clientVersion and only take the timestamp from engines that we know use timestamp defined in the same format |
||
} else { | ||
None | ||
}; | ||
ion-elgreco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let ts = match timestamp { | ||
Some(ts) => ts, | ||
_ => { | ||
let meta = self | ||
.object_store() | ||
.head(&commit_uri_from_version(version)) | ||
.await?; | ||
meta.last_modified.timestamp_millis() | ||
} | ||
}; | ||
// also cache timestamp for version | ||
self.version_timestamp.insert(version, ts); | ||
|
||
Ok(ts) | ||
} | ||
} | ||
|
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.
Instead of loading the version each time, we could also just do this
self.state.commit_infos().get(version).unwrap().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.
@ion-elgreco Setting aside the concerns I have shared with reliance on
commitInfo
, I believe that invocation is not guaranteed to return the right versioned information if the version has not been loaded already.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 think aloud here but in general you shouldn't be able to restore to a version of a table that's above the current loaded table version