feat: add get dataset method on NativeTable (#2021)

I want to public the dataset method from native table, then I can use
more lance method like order_by which is not exposed in the lancedb
crate.
This commit is contained in:
Bob Liu
2025-03-14 02:15:28 +08:00
committed by GitHub
parent 14677d7c18
commit 5c00b2904c
3 changed files with 595 additions and 304 deletions

883
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,11 @@ use std::io::Cursor;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use crate::index::Index;
use crate::index::IndexStatistics;
use crate::query::{QueryFilter, QueryRequest, Select, VectorQueryRequest};
use crate::table::{AddDataMode, AnyQuery, Filter};
use crate::utils::{supported_btree_data_type, supported_vector_data_type};
use crate::{index::Index, table::dataset};
use crate::{DistanceType, Error, Table};
use arrow_array::RecordBatchReader;
use arrow_ipc::reader::FileReader;
@@ -396,6 +396,9 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
fn name(&self) -> &str {
&self.name
}
fn dataset(&self) -> &dataset::DatasetConsistencyWrapper {
unimplemented!()
}
async fn version(&self) -> Result<u64> {
self.describe().await.map(|desc| desc.version)
}

View File

@@ -410,6 +410,8 @@ pub trait BaseTable: std::fmt::Display + std::fmt::Debug + Send + Sync {
fn as_any(&self) -> &dyn std::any::Any;
/// Get the name of the table.
fn name(&self) -> &str;
/// Get the dataset of the table.
fn dataset(&self) -> &dataset::DatasetConsistencyWrapper;
/// Get the arrow [Schema] of the table.
async fn schema(&self) -> Result<SchemaRef>;
/// Count the number of rows in this table.
@@ -581,6 +583,11 @@ impl Table {
self.inner.name()
}
/// Get the dataset of the table.
pub fn dataset(&self) -> &dataset::DatasetConsistencyWrapper {
self.inner.dataset()
}
/// Get the arrow [Schema] of the table.
pub async fn schema(&self) -> Result<SchemaRef> {
self.inner.schema().await
@@ -1858,6 +1865,10 @@ impl BaseTable for NativeTable {
self.name.as_str()
}
fn dataset(&self) -> &dataset::DatasetConsistencyWrapper {
&self.dataset
}
async fn version(&self) -> Result<u64> {
Ok(self.dataset.get().await?.version().version)
}