mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-28 05:24:00 +00:00
fix: preserve original branch across tag time travel
This commit is contained in:
@@ -2094,6 +2094,40 @@ impl Table {
|
||||
})
|
||||
}
|
||||
|
||||
/// The branch to reattach to after time travel, for pickle reopen state.
|
||||
pub fn _tracking_branch(&self) -> PyResult<Option<String>> {
|
||||
let inner = self.inner_ref()?;
|
||||
Ok(inner
|
||||
.dataset()
|
||||
.map(|dataset| dataset.tracking_branch())
|
||||
.unwrap_or_else(|| inner.current_branch()))
|
||||
}
|
||||
|
||||
/// Reopen an exact snapshot without changing the handle's tracking branch.
|
||||
#[pyo3(signature = (branch, version))]
|
||||
pub fn _checkout_snapshot(
|
||||
self_: PyRef<'_, Self>,
|
||||
branch: Option<String>,
|
||||
version: u64,
|
||||
) -> PyResult<Bound<'_, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
if let Some(dataset) = inner.dataset() {
|
||||
dataset
|
||||
.as_time_travel(Ref::Version(branch, Some(version)))
|
||||
.await
|
||||
.infer_error()
|
||||
} else {
|
||||
if inner.current_branch() != branch {
|
||||
return Err(PyValueError::new_err(
|
||||
"snapshot branch differs from the table handle's branch",
|
||||
));
|
||||
}
|
||||
inner.checkout(version).await.infer_error()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[pyo3(signature = (version=None))]
|
||||
pub fn restore(
|
||||
self_: PyRef<'_, Self>,
|
||||
|
||||
Reference in New Issue
Block a user