fix: Allow converting from NativeTable to Table (#1069)

This commit is contained in:
Will Jones
2024-03-07 08:33:46 -08:00
committed by GitHub
parent 7fb8a732a5
commit a7d66032aa
4 changed files with 12 additions and 6 deletions

View File

@@ -323,7 +323,7 @@ impl JsTable {
.and_then(|val| val.downcast::<JsNumber, _>(&mut cx).ok())
.map(|val| val.value(&mut cx) as i64)
.unwrap_or_else(|| 2 * 7 * 24 * 60); // 2 weeks
let older_than = chrono::Duration::minutes(older_than);
let older_than = chrono::Duration::try_minutes(older_than).unwrap();
let delete_unverified: Option<bool> = Some(
cx.argument_opt(1)
.and_then(|val| val.downcast::<JsBoolean, _>(&mut cx).ok())

View File

@@ -796,10 +796,10 @@ mod tests {
let tmp_dir = tempdir().unwrap();
let mut names = Vec::with_capacity(100);
for _ in 0..100 {
let name = uuid::Uuid::new_v4().to_string();
let mut name = uuid::Uuid::new_v4().to_string();
names.push(name.clone());
let table_name = name + ".lance";
create_dir_all(tmp_dir.path().join(&table_name)).unwrap();
name.push_str(".lance");
create_dir_all(tmp_dir.path().join(&name)).unwrap();
}
names.sort();

View File

@@ -65,7 +65,6 @@ mod tests {
use super::*;
use arrow_array::{Float32Array, Int64Array, RecordBatch};
use arrow_ipc::writer::StreamWriter;
use arrow_schema::{DataType, Field, Schema};
use std::sync::Arc;

View File

@@ -504,6 +504,13 @@ impl Table {
}
}
impl From<NativeTable> for Table {
fn from(table: NativeTable) -> Self {
Self {
inner: Arc::new(table),
}
}
}
/// A table in a LanceDB database.
#[derive(Debug, Clone)]
pub struct NativeTable {
@@ -1141,7 +1148,7 @@ impl TableInternal for NativeTable {
.compaction;
stats.prune = self
.optimize(OptimizeAction::Prune {
older_than: Duration::days(7),
older_than: Duration::try_days(7).unwrap(),
delete_unverified: None,
})
.await?