mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-04 10:52:56 +00:00
fix: make checkout_latest force a reload (#1064)
#1002 accidentally changed `checkout_latest` to do nothing if the table was already in latest mode. This PR makes sure it forces a reload of the table (if there is a newer version).
This commit is contained in:
@@ -636,9 +636,14 @@ impl NativeTable {
|
||||
})
|
||||
}
|
||||
|
||||
/// Checkout the latest version of this [NativeTable].
|
||||
///
|
||||
/// This will force the table to be reloaded from disk, regardless of the
|
||||
/// `read_consistency_interval` set.
|
||||
pub async fn checkout_latest(&self) -> Result<Self> {
|
||||
let mut dataset = self.dataset.duplicate().await;
|
||||
dataset.as_latest(self.read_consistency_interval).await?;
|
||||
dataset.reload().await?;
|
||||
Ok(Self {
|
||||
dataset,
|
||||
..self.clone()
|
||||
@@ -1943,6 +1948,9 @@ mod tests {
|
||||
match interval {
|
||||
None => {
|
||||
assert_eq!(table2.count_rows(None).await.unwrap(), 0);
|
||||
let table2_native =
|
||||
table2.as_native().unwrap().checkout_latest().await.unwrap();
|
||||
assert_eq!(table2_native.count_rows(None).await.unwrap(), 1);
|
||||
}
|
||||
Some(0) => {
|
||||
assert_eq!(table2.count_rows(None).await.unwrap(), 1);
|
||||
|
||||
@@ -156,7 +156,7 @@ impl DatasetConsistencyWrapper {
|
||||
self.0.write().await.set_latest(dataset);
|
||||
}
|
||||
|
||||
async fn reload(&self) -> Result<()> {
|
||||
pub async fn reload(&self) -> Result<()> {
|
||||
self.0.write().await.reload().await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user