From ee6c18f2077a5983ae0ff1665e18a9f4e11037c2 Mon Sep 17 00:00:00 2001 From: Rob Meng Date: Fri, 27 Sep 2024 10:20:02 -0400 Subject: [PATCH] feat: expose underlying dataset uri of the table (#1704) --- rust/lancedb/src/remote/table.rs | 3 +++ rust/lancedb/src/table.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/rust/lancedb/src/remote/table.rs b/rust/lancedb/src/remote/table.rs index 2a42ce67..88abfc38 100644 --- a/rust/lancedb/src/remote/table.rs +++ b/rust/lancedb/src/remote/table.rs @@ -325,6 +325,9 @@ impl TableInternal for RemoteTable { message: "table_definition is not supported on LanceDB cloud.".into(), }) } + fn dataset_uri(&self) -> &str { + "NOT_SUPPORTED" + } } #[derive(Serialize)] diff --git a/rust/lancedb/src/table.rs b/rust/lancedb/src/table.rs index 109ebcd4..daff561d 100644 --- a/rust/lancedb/src/table.rs +++ b/rust/lancedb/src/table.rs @@ -419,6 +419,7 @@ pub(crate) trait TableInternal: std::fmt::Display + std::fmt::Debug + Send + Syn async fn checkout_latest(&self) -> Result<()>; async fn restore(&self) -> Result<()>; async fn table_definition(&self) -> Result; + fn dataset_uri(&self) -> &str; } /// A Table is a collection of strong typed Rows. @@ -950,6 +951,13 @@ impl Table { pub async fn list_indices(&self) -> Result> { self.inner.list_indices().await } + + /// Get the underlying dataset URI + /// + /// Warning: This is an internal API and the return value is subject to change. + pub fn dataset_uri(&self) -> &str { + self.inner.dataset_uri() + } } impl From for Table { @@ -2172,6 +2180,10 @@ impl TableInternal for NativeTable { Ok(IndexConfig { index_type, columns, name }) }).collect::>>() } + + fn dataset_uri(&self) -> &str { + self.uri.as_str() + } } #[cfg(test)]