pub struct Table { /* private fields */ }Expand description
A Table is a collection of strong typed Rows.
The type of the each row is defined in Apache Arrow Schema.
Implementations§
Source§impl Table
impl Table
pub fn new(inner: Arc<dyn BaseTable>, database: Arc<dyn Database>) -> Self
pub fn base_table(&self) -> &Arc<dyn BaseTable> ⓘ
pub fn database(&self) -> &Arc<dyn Database> ⓘ
pub fn embedding_registry(&self) -> &Arc<dyn EmbeddingRegistry> ⓘ
Sourcepub fn as_native(&self) -> Option<&NativeTable>
pub fn as_native(&self) -> Option<&NativeTable>
Cast as NativeTable, or return None it if is not a NativeTable.
Warning: This function will be removed soon (features exclusive to NativeTable will be added to Table)
Sourcepub fn dataset(&self) -> Option<&DatasetConsistencyWrapper>
pub fn dataset(&self) -> Option<&DatasetConsistencyWrapper>
Get the dataset of the table if it is a native table
Returns None otherwise
Sourcepub async fn count_rows(&self, filter: Option<String>) -> Result<usize>
pub async fn count_rows(&self, filter: Option<String>) -> Result<usize>
Count the number of rows in this dataset.
§Arguments
filterif present, only count rows matching the filter
Sourcepub async fn blob_columns(&self) -> Result<Vec<String>>
pub async fn blob_columns(&self) -> Result<Vec<String>>
Names of the blob v2 columns in this table, in declaration order.
Nested blobs use dotted paths (e.g. info.blob). Returns
Error::NotSupported on table types without blob support.
Sourcepub async fn fetch_blobs(
&self,
column: impl AsRef<str>,
row_ids: &[u64],
) -> Result<LargeBinaryArray>
pub async fn fetch_blobs( &self, column: impl AsRef<str>, row_ids: &[u64], ) -> Result<LargeBinaryArray>
Materialize blob bytes for the given row ids.
Output matches row_ids in length and order. Null blobs are null;
valid empty blobs contain empty byte strings. Prefer
Self::fetch_blob_files for large selections.
use arrow_array::UInt64Array;
use futures::TryStreamExt;
use lancedb::query::{ExecutableQuery, QueryBase};
let mut stream = table.query().with_row_id().limit(10).execute().await?;
while let Some(batch) = stream.try_next().await? {
let row_ids = batch
.column_by_name("_rowid")
.unwrap()
.as_any()
.downcast_ref::<UInt64Array>()
.unwrap();
let images = table.fetch_blobs("image", row_ids.values()).await?;
let _ = images;
}Returns Error::InvalidInput when the column does not exist or is
not a blob v2 column, and Error::NotSupported on table types
without blob support.
Sourcepub async fn fetch_blob_ranges(
&self,
column: impl AsRef<str>,
requests: impl IntoIterator<Item = BlobRangeRequest>,
) -> Result<LargeBinaryArray>
pub async fn fetch_blob_ranges( &self, column: impl AsRef<str>, requests: impl IntoIterator<Item = BlobRangeRequest>, ) -> Result<LargeBinaryArray>
Materialize row-specific ranges from a blob v2 column.
Each request contains a row id and a blob-local offset and length. Requests may be duplicated or reordered, including multiple ranges for the same blob. The output has the same length and order as the requests. Null blobs produce null output slots; empty ranges on non-null blobs produce empty byte strings.
use lancedb::blob::BlobRangeRequest;
let ranges = table
.fetch_blob_ranges(
"image",
[
BlobRangeRequest::new(row_id, 0, 1024),
BlobRangeRequest::new(row_id, 4096, 1024),
],
)
.await?;Returns an error when a range is invalid, a requested row id does not
exist, or the column is not a blob v2 column. Returns
Error::NotSupported on table types without blob support.
Sourcepub async fn fetch_blob_files(
&self,
column: impl AsRef<str>,
row_ids: &[u64],
) -> Result<Vec<Option<BlobFile>>>
pub async fn fetch_blob_files( &self, column: impl AsRef<str>, row_ids: &[u64], ) -> Result<Vec<Option<BlobFile>>>
Open lazy BlobFile handles for the given row ids.
Same length and order as row_ids. Null rows are None. Bytes are not
read from disk until a call to BlobFile::read.
let handles = table.fetch_blob_files("image", row_ids).await?;
if let Some(Some(first)) = handles.first() {
let bytes = first.read().await?;
println!("first blob is {} bytes", bytes.len());
}Sourcepub fn add<T: Scannable + 'static>(&self, data: T) -> AddDataBuilder
pub fn add<T: Scannable + 'static>(&self, data: T) -> AddDataBuilder
Insert new records into this Table
§Arguments
datadata to be added to the Tableoptionsoptions to control how data is added
Sourcepub fn update(&self) -> UpdateBuilder
pub fn update(&self) -> UpdateBuilder
Update existing records in the Table
An update operation can be used to adjust existing values. Use the returned builder to specify which columns to update. The new value can be a literal value (e.g. replacing nulls with some default value) or an expression applied to the old value (e.g. incrementing a value)
An optional condition can be specified (e.g. “only update if the old value is 0”)
Note: if your condition is something like “some_id_column == 7” and
you are updating many rows (with different ids) then you will get
better performance with a single [merge_insert] call instead of
repeatedly calilng this method.
Sourcepub async fn delete(
&self,
predicate: impl Into<Predicate<'_>>,
) -> Result<DeleteResult>
pub async fn delete( &self, predicate: impl Into<Predicate<'_>>, ) -> Result<DeleteResult>
Delete the rows from table that match the predicate.
§Arguments
predicate- A SQL string (&str) or DataFusion expression (&Expr) that selects the rows to delete.
§Example
use datafusion_expr::{col, lit};
let tmpdir = tempfile::tempdir().unwrap();
let db = lancedb::connect(tmpdir.path().to_str().unwrap())
.execute()
.await
.unwrap();
let schema = Arc::new(Schema::new(vec![
Field::new("id", DataType::Int32, false),
Field::new("vector", DataType::FixedSizeList(
Arc::new(Field::new("item", DataType::Float32, true)), 128), true),
]));
let data = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_iter_values(0..10)),
Arc::new(
FixedSizeListArray::from_iter_primitive::<Float32Type, _, _>(
(0..10).map(|_| Some(vec![Some(1.0); 128])),
128,
),
),
],
)
.unwrap();
let tbl = db
.create_table("delete_test", data)
.execute()
.await
.unwrap();
// Using a SQL string:
tbl.delete("id > 5").await.unwrap();
// Using a DataFusion expression:
let expr = col("id").lt(lit(4));
tbl.delete(&expr).await.unwrap();Sourcepub fn create_index(
&self,
columns: &[impl AsRef<str>],
index: Index,
) -> IndexBuilder
pub fn create_index( &self, columns: &[impl AsRef<str>], index: Index, ) -> IndexBuilder
Create an index on the provided column(s).
Indices are used to speed up searches and are often needed when the size of the table becomes large (the exact size depends on many factors but somewhere between 100K rows and 1M rows is a good rule of thumb)
There are a variety of indices available. They are described more in
crate::index::Index. The simplest thing to do is to use index::Index::Auto which
will attempt to create the most useful index based on the column type and column
statistics. BTree index is created by default for numeric, temporal, and
string columns.
Once an index is created it will remain until the data is overwritten (e.g. an add operation with mode overwrite) or the indexed column is dropped.
Indices are not automatically updated with new data. If you add new data to the table then the index will not include the new rows. However, a table search will still consider the unindexed rows. Searches will issue both an indexed search (on the data covered by the index) and a flat search (on the unindexed data) and the results will be combined.
If there is enough unindexed data then the flat search will become slow and the index should be optimized. Optimizing an index will add any unindexed data to the existing index without rerunning the full index creation process. For more details see Table::optimize.
Note: Multi-column (composite) indices are not currently supported. However, they will be supported in the future and the API is designed to be compatible with them.
§Examples
use lancedb::index::Index;
let tmpdir = tempfile::tempdir().unwrap();
let db = lancedb::connect(tmpdir.path().to_str().unwrap())
.execute()
.await
.unwrap();
// Create IVF PQ index on the "vector" column by default.
tbl.create_index(&["vector"], Index::Auto)
.execute()
.await
.unwrap();
// Create a BTree index on the "id" column.
tbl.create_index(&["id"], Index::Auto)
.execute()
.await
.unwrap();
// Create a LabelList index on the "tags" column.
tbl.create_index(&["tags"], Index::LabelList(Default::default()))
.execute()
.await
.unwrap();Sourcepub fn create_index_with_timeout(
&self,
columns: &[impl AsRef<str>],
index: Index,
wait_timeout: Option<Duration>,
) -> IndexBuilder
pub fn create_index_with_timeout( &self, columns: &[impl AsRef<str>], index: Index, wait_timeout: Option<Duration>, ) -> IndexBuilder
See Table::create_index For remote tables, this allows an optional wait_timeout to poll until asynchronous indexing is complete
Sourcepub fn merge_insert(&self, on: &[&str]) -> MergeInsertBuilder
pub fn merge_insert(&self, on: &[&str]) -> MergeInsertBuilder
Create a builder for a merge insert operation
This operation can add rows, update rows, and remove rows all in a single transaction. It is a very generic tool that can be used to create behaviors like “insert if not exists”, “update or insert (i.e. upsert)”, or even replace a portion of existing data with new data (e.g. replace all data where month=“january”)
The merge insert operation works by combining new data from a source table with existing data in a target table by using a join. There are three categories of records.
“Matched” records are records that exist in both the source table and the target table. “Not matched” records exist only in the source table (e.g. these are new data) “Not matched by source” records exist only in the target table (this is old data)
The builder returned by this method can be used to customize what should happen for each category of data.
Please note that the data may appear to be reordered as part of this operation. This is because updated rows will be deleted from the dataset and then reinserted at the end with the new values.
§Arguments
onOne or more columns to join on. This is how records from the source table and target table are matched. Typically this is some kind of key or id column.
§Examples
let tmpdir = tempfile::tempdir().unwrap();
let db = lancedb::connect(tmpdir.path().to_str().unwrap())
.execute()
.await
.unwrap();
let new_data = RecordBatchIterator::new(
vec![RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_iter_values(0..10)),
Arc::new(
FixedSizeListArray::from_iter_primitive::<Float32Type, _, _>(
(0..10).map(|_| Some(vec![Some(1.0); 128])),
128,
),
),
],
)
.unwrap()]
.into_iter()
.map(Ok),
schema.clone(),
);
// Perform an upsert operation
let mut merge_insert = tbl.merge_insert(&["id"]);
merge_insert
.when_matched_update_all(None)
.when_not_matched_insert_all();
merge_insert.execute(Box::new(new_data)).await.unwrap();Sourcepub fn query(&self) -> Query
pub fn query(&self) -> Query
Create a Query Builder.
Queries allow you to search your existing data. By default the query will return all the data in the table in no particular order. The builder returned by this method can be used to control the query using filtering, vector similarity, sorting, and more.
Note: By default, all columns are returned. For best performance, you should
only fetch the columns you need. See [Query::select_with_projection] for
more details.
When appropriate, various indices and statistics will be used to accelerate the query.
§Examples
§Vector search
This example will find the 10 rows whose value in the “vector” column are closest to the query vector [1.0, 2.0, 3.0]. If an index has been created on the “vector” column then this will perform an ANN search.
The [Query::refine_factor] and [Query::nprobes] methods are used to
control the recall / latency tradeoff of the search.
use crate::lancedb::Table;
use crate::lancedb::query::ExecutableQuery;
let stream = tbl
.query()
.nearest_to(&[1.0, 2.0, 3.0])
.unwrap()
.refine_factor(5)
.nprobes(10)
.execute()
.await
.unwrap();
let batches: Vec<RecordBatch> = stream.try_collect().await.unwrap();§SQL-style filter
This query will return up to 1000 rows whose value in the id column
is greater than 5. LanceDb supports a broad set of filtering functions.
use crate::lancedb::Table;
use crate::lancedb::query::{ExecutableQuery, QueryBase};
let stream = tbl
.query()
.only_if("id > 5")
.limit(1000)
.execute()
.await
.unwrap();
let batches: Vec<RecordBatch> = stream.try_collect().await.unwrap();§Full scan
This query will return everything in the table in no particular order.
use crate::lancedb::Table;
use crate::lancedb::query::ExecutableQuery;
let stream = tbl.query().execute().await.unwrap();
let batches: Vec<RecordBatch> = stream.try_collect().await.unwrap();Sourcepub fn take_offsets(&self, offsets: Vec<u64>) -> TakeQuery
pub fn take_offsets(&self, offsets: Vec<u64>) -> TakeQuery
Extract rows from the dataset using dataset offsets.
Dataset offsets are 0-indexed and relative to the current version of the table. They are not stable. A row with an offset of N may have a different offset in a different version of the table (e.g. if an earlier row is deleted).
Offsets are useful for sampling as the set of all valid offsets is easily known in advance to be [0, len(table)).
No guarantees are made regarding the order in which results are returned. If you desire an output order that matches the order of the given offsets, you will need to add the row offset column to the output and align it yourself.
§Parameters
offsets: list[int] The offsets to take.
§Returns
pa.RecordBatch A record batch containing the rows at the given offsets.
Sourcepub fn take_row_ids(&self, row_ids: Vec<u64>) -> TakeQuery
pub fn take_row_ids(&self, row_ids: Vec<u64>) -> TakeQuery
Extract rows from the dataset using row ids.
Row ids are not stable and are relative to the current version of the table. They can change due to compaction and updates.
Even so, row ids are more stable than offsets and can be useful in some situations.
There is an ongoing effort to make row ids stable which is tracked at https://github.com/lancedb/lancedb/issues/1120
§No guarantees are made regarding the order in which results are returned. If you desire an output order that matches the order of the given ids, you will need to add the row id column to the output and align it yourself. Parameters
row_ids: list[int] The row ids to take.
Sourcepub fn vector_search(&self, query: impl IntoQueryVector) -> Result<VectorQuery>
pub fn vector_search(&self, query: impl IntoQueryVector) -> Result<VectorQuery>
Search the table with a given query vector.
This is a convenience method for preparing a vector query and
is the same thing as calling nearest_to on the builder returned
by query. See Query::nearest_to for more details.
Sourcepub async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats>
pub async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats>
Optimize the on-disk data and indices for better performance.
Modeled after VACUUM in PostgreSQL.
Optimization is discussed in more detail in the OptimizeAction documentation and covers three operations:
- Compaction: Merges small files into larger ones
- Prune: Removes old versions of the dataset
- Index: Optimizes the indices, adding new data to existing indices
The frequency an application should call optimize is based on the frequency of data modifications. If data is frequently added, deleted, or updated then optimize should be run frequently. A good rule of thumb is to run optimize if you have added or modified 100,000 or more records or run more than 20 data modification operations.
Sourcepub fn add_columns(&self) -> AddColumnsBuilder
pub fn add_columns(&self) -> AddColumnsBuilder
Add new columns to the table, providing values to fill in.
Sourcepub async fn alter_columns(
&self,
alterations: &[ColumnAlteration],
) -> Result<AlterColumnsResult>
pub async fn alter_columns( &self, alterations: &[ColumnAlteration], ) -> Result<AlterColumnsResult>
Change a column’s name or nullability.
Sourcepub async fn update_field_metadata(
&self,
updates: &[FieldMetadataUpdate],
) -> Result<UpdateFieldMetadataResult>
pub async fn update_field_metadata( &self, updates: &[FieldMetadataUpdate], ) -> Result<UpdateFieldMetadataResult>
Update per-field metadata (merges by default).
Sourcepub async fn drop_columns(&self, columns: &[&str]) -> Result<DropColumnsResult>
pub async fn drop_columns(&self, columns: &[&str]) -> Result<DropColumnsResult>
Remove columns from the table.
Sourcepub async fn set_unenforced_primary_key<I, S>(&self, columns: I) -> Result<()>
pub async fn set_unenforced_primary_key<I, S>(&self, columns: I) -> Result<()>
Set the unenforced primary key for this table to a single column.
“Unenforced” means LanceDB does not check uniqueness on writes; the
column is recorded in the schema as the primary key so that features
such as merge_insert can use it.
Only single-column primary keys are supported, and the key cannot be
changed once set — calling this on a table that already has an
unenforced primary key fails. columns is an iterable for binding
ergonomics but must yield exactly one column:
table.set_unenforced_primary_key(["id"])
Sourcepub async fn set_lsm_write_spec(&self, spec: LsmWriteSpec) -> Result<()>
pub async fn set_lsm_write_spec(&self, spec: LsmWriteSpec) -> Result<()>
Install an LsmWriteSpec on this table, selecting Lance’s MemWAL
LSM-style write path for future merge_insert calls.
LsmWriteSpec chooses one of three sharding strategies:
LsmWriteSpec::bucket— hash-bucket writes by a scalar column.LsmWriteSpec::identity— shard by the raw value of a scalar column.LsmWriteSpec::unsharded— route every write to a single shard.
§Example
table
.set_lsm_write_spec(
LsmWriteSpec::bucket("id", 16).with_maintained_indexes(["id_idx"]),
)
.await?;Sourcepub async fn unset_lsm_write_spec(&self) -> Result<()>
pub async fn unset_lsm_write_spec(&self) -> Result<()>
Remove the LsmWriteSpec from this table, reverting to the standard
merge_insert write path.
Errors if no spec is currently set.
Sourcepub async fn get_lsm_write_spec(&self) -> Result<Option<LsmWriteSpec>>
pub async fn get_lsm_write_spec(&self) -> Result<Option<LsmWriteSpec>>
Read the LsmWriteSpec currently installed on this table.
Returns Ok(None) when the MemWAL LSM write path is not enabled (no
spec has been set, or it was removed with Table::unset_lsm_write_spec).
The returned spec — including its LsmWriteSpec::maintained_indexes and
LsmWriteSpec::writer_config_defaults — mirrors what was passed to
Table::set_lsm_write_spec.
§Example
if let Some(spec) = table.get_lsm_write_spec().await? {
println!("LSM write path enabled: {:?}", spec);
}Sourcepub async fn checkpoint_lsm(&self) -> Result<()>
pub async fn checkpoint_lsm(&self) -> Result<()>
Converge this table’s LSM write path into its base table.
One flush to seal every memtable into L0, then compaction triggers
until every generation that existed at that moment has reached base.
The loop runs client-side, reading progress from get_lsm_stats, so
there is no held socket and nothing to reconcile if you drop this
future partway through.
Best-effort. Generations created after the opening flush are deliberately not waited on — that is what lets this terminate on a table taking writes. Idempotent and safe on a cadence: an already-converged table costs two round trips and triggers nothing.
No deadline, and the caller owns that. It returns when the target
generations are gone, propagates a terminal server fault, and
otherwise waits however long the server takes. A slow table and a
stuck one are the same picture from here: the compactor pool is shared
across every table on the node, so a checkpoint queued behind
unrelated work is indistinguishable from one that is merging. Wrap
this in tokio::time::timeout for a wall-clock bound; abandoning it
partway costs nothing.
§Example
let before = table.get_lsm_stats(false).await?;
table.checkpoint_lsm().await?;
let after = table.get_lsm_stats(false).await?;Sourcepub async fn flush_lsm(&self) -> Result<()>
pub async fn flush_lsm(&self) -> Result<()>
Seal every bucket’s active memtable into L0 without touching the base table.
Independently useful: flushing makes memtable rows readable from L0 at a lower per-query cost. On a node that has not claimed this table it claims it and replays the WAL log first — reporting “nothing to flush” without replaying would lie about durable data.
Sourcepub async fn compact_lsm(&self) -> Result<()>
pub async fn compact_lsm(&self) -> Result<()>
Run one bounded L0 → base compaction pass per bucket, reporting what it merged and what is left.
One pass, not convergence: that bounds each request’s cost and gives a caller driving its own cadence a progress signal per round trip.
Sourcepub async fn get_lsm_stats(
&self,
include_generation_rows: bool,
) -> Result<Option<LsmStats>>
pub async fn get_lsm_stats( &self, include_generation_rows: bool, ) -> Result<Option<LsmStats>>
Read live per-bucket LSM state.
Answers “how far behind is my fresh tier”, “which bucket is hot”, and “why is my fresh-tier vector search brute-force”. Mutates no table state, though on a node that has not claimed this table it claims it, exactly as a read would.
include_generation_rows reports a row count per L0 generation. Off by
default: each count opens an uncached Lance dataset, and
checkpoint_lsm polls this needing only generation numbers.
Ok(None) only when the LSM write path is not enabled, matching
Table::get_lsm_write_spec. Stats is fresh-tier only, so with the
WAL off there is no manifest to report and a struct of zeros would
read as measurements.
Do not build a checkpoint’s termination on this: the completion
predicate lives in the flush and compact responses.
Sourcepub async fn close_lsm_writers(&self) -> Result<()>
pub async fn close_lsm_writers(&self) -> Result<()>
Drain and close any cached MemWAL shard writers held for this table.
When an LsmWriteSpec is installed, merge_insert opens MemWAL shard
writers and caches them for reuse across calls. This closes them,
flushing pending data; writers reopen lazily on the next merge_insert.
It is a no-op when no writers are cached.
Sourcepub async fn version(&self) -> Result<u64>
pub async fn version(&self) -> Result<u64>
Retrieve the version of the table
LanceDb supports versioning. Every operation that modifies the table increases
version. As long as a version hasn’t been deleted you can [Self::checkout] that
version to view the data at that point. In addition, you can [Self::restore] the
version to replace the current table with a previous version.
Sourcepub async fn checkout(&self, version: u64) -> Result<()>
pub async fn checkout(&self, version: u64) -> Result<()>
Checks out a specific version of the Table
Any read operation on the table will now access the data at the checked out version. As a consequence, calling this method will disable any read consistency interval that was previously set.
This is a read-only operation that turns the table into a sort of “view”
or “detached head”. Other table instances will not be affected. To make the change
permanent you can use the [Self::restore] method.
Any operation that modifies the table will fail while the table is in a checked out state.
To return the table to a normal state use [Self::checkout_latest]
Sourcepub async fn checkout_tag(&self, tag: &str) -> Result<()>
pub async fn checkout_tag(&self, tag: &str) -> Result<()>
Checks out a specific version of the Table by tag
Any read operation on the table will now access the data at the version referenced by the tag. As a consequence, calling this method will disable any read consistency interval that was previously set.
This is a read-only operation that turns the table into a sort of “view”
or “detached head”. Other table instances will not be affected. To make the change
permanent you can use the [Self::restore] method.
Any operation that modifies the table will fail while the table is in a checked out state.
To return the table to a normal state use [Self::checkout_latest]
Sourcepub async fn checkout_latest(&self) -> Result<()>
pub async fn checkout_latest(&self) -> Result<()>
Ensures the table is pointing at the latest version
This can be used to manually update a table when the read_consistency_interval is None
It can also be used to undo a [Self::checkout] operation
Sourcepub async fn restore(&self) -> Result<()>
pub async fn restore(&self) -> Result<()>
Restore the table to the currently checked out version
This operation will fail if checkout has not been called previously
This operation will overwrite the latest version of the table with a previous version. Any changes made since the checked out version will no longer be visible.
Once the operation concludes the table will no longer be in a checked out state and the read_consistency_interval, if any, will apply.
Sourcepub async fn list_versions(&self) -> Result<Vec<Version>>
pub async fn list_versions(&self) -> Result<Vec<Version>>
List all the versions of the table
Sourcepub async fn list_indices(&self) -> Result<Vec<IndexConfig>>
pub async fn list_indices(&self) -> Result<Vec<IndexConfig>>
List all indices that have been created with Self::create_index
Sourcepub async fn tokenize(
&self,
query: &str,
index_name: &str,
) -> Result<Vec<FtsToken>>
pub async fn tokenize( &self, query: &str, index_name: &str, ) -> Result<Vec<FtsToken>>
Tokenize a full-text search query using the tokenizer configured on an FTS index.
Model-backed tokenizers such as jieba/* and lindera/* are rebuilt in
the client process from index metadata. For remote tables, this means the
same tokenizer model files must also exist locally.
Sourcepub async fn tokenize_with_column(
&self,
query: &str,
column: &str,
) -> Result<Vec<FtsToken>>
pub async fn tokenize_with_column( &self, query: &str, column: &str, ) -> Result<Vec<FtsToken>>
Tokenize a full-text search query using the tokenizer configured on the FTS index for a column.
The column must have exactly one FTS index. Model-backed tokenizers such
as jieba/* and lindera/* are rebuilt in the client process from
index metadata. For remote tables, this means the same tokenizer model
files must also exist locally.
Sourcepub async fn uri(&self) -> Result<String>
pub async fn uri(&self) -> Result<String>
Get the table URI (storage location)
Returns the full storage location of the table (e.g., S3/GCS path). For remote tables, this fetches the location from the server via describe.
Sourcepub async fn storage_options(&self) -> Option<HashMap<String, String>>
👎Deprecated since 0.25.0: Use initial_storage_options() instead
pub async fn storage_options(&self) -> Option<HashMap<String, String>>
Use initial_storage_options() instead
Get the storage options used when opening this table, if any.
Warning: This is an internal API and the return value is subject to change.
Sourcepub async fn initial_storage_options(&self) -> Option<HashMap<String, String>>
pub async fn initial_storage_options(&self) -> Option<HashMap<String, String>>
Get the initial storage options that were passed in when opening this table.
For dynamically refreshed options (e.g., credential vending), use Self::latest_storage_options.
Warning: This is an internal API and the return value is subject to change.
Sourcepub async fn latest_storage_options(
&self,
) -> Result<Option<HashMap<String, String>>>
pub async fn latest_storage_options( &self, ) -> Result<Option<HashMap<String, String>>>
Get the latest storage options, refreshing from provider if configured.
This method is useful for credential vending scenarios where storage options may be refreshed dynamically. If no dynamic provider is configured, this returns the initial static options.
Warning: This is an internal API and the return value is subject to change.
Sourcepub async fn index_stats(
&self,
index_name: impl AsRef<str>,
) -> Result<Option<IndexStatistics>>
pub async fn index_stats( &self, index_name: impl AsRef<str>, ) -> Result<Option<IndexStatistics>>
Get statistics about an index. Returns None if the index does not exist.
Sourcepub async fn drop_index(&self, name: &str) -> Result<()>
pub async fn drop_index(&self, name: &str) -> Result<()>
Drop an index from the table.
Note: This is not yet available in LanceDB cloud.
This does not delete the index from disk, it just removes it from the table.
To delete the index, run Self::optimize() after dropping the index.
Use Self::list_indices() to find the names of the indices.
Sourcepub async fn prewarm_index(&self, name: &str) -> Result<()>
pub async fn prewarm_index(&self, name: &str) -> Result<()>
Prewarm an index in the table.
This is a hint to the database that the index will be accessed in the future and should be loaded into memory if possible. This can reduce cold-start latency for subsequent queries.
This call initiates prewarming and returns once the request is accepted. It is idempotent and safe to call from multiple clients concurrently.
It is generally wasteful to call this if the index does not fit into the available cache. Not all index types support prewarming; unsupported indices will silently ignore the request.
Use Self::list_indices() to find the names of the indices.
Sourcepub async fn prewarm_data(&self, columns: Option<Vec<String>>) -> Result<()>
pub async fn prewarm_data(&self, columns: Option<Vec<String>>) -> Result<()>
Prewarm data for the table.
This is a hint to the database that the given columns will be accessed in the future and the database should prefetch the data if possible. This can reduce cold-start latency for subsequent queries. Currently only supported on remote tables.
This call initiates prewarming and returns once the request is accepted. It is idempotent and safe to call from multiple clients concurrently — calling it on already-prewarmed columns is a no-op on the server.
This operation has a large upfront cost but can speed up future queries that need to fetch the given columns. Large columns such as embeddings or binary data may not be practical to prewarm. This feature is intended for workloads that issue many queries against the same columns.
If columns is None, all columns are prewarmed.
Sourcepub async fn wait_for_index(
&self,
index_names: &[&str],
timeout: Duration,
) -> Result<()>
pub async fn wait_for_index( &self, index_names: &[&str], timeout: Duration, ) -> Result<()>
Poll until the columns are fully indexed. Will return Error::Timeout if the columns are not fully indexed within the timeout.
Get the tags manager.
Sourcepub async fn create_branch(
&self,
name: &str,
from: impl Into<Ref>,
) -> Result<Self>
pub async fn create_branch( &self, name: &str, from: impl Into<Ref>, ) -> Result<Self>
Create a new branch from from (a version, tag, or branch)
Sourcepub async fn checkout_branch(
&self,
name: &str,
version: Option<u64>,
) -> Result<Self>
pub async fn checkout_branch( &self, name: &str, version: Option<u64>, ) -> Result<Self>
Check out an existing branch and return a handle scoped to it.
With version set, the returned handle is pinned to that version of the
branch: a read-only, detached view (as with Self::checkout). With
version as None it tracks the branch’s latest and stays writable.
let exp_at_v3 = table.checkout_branch("exp", Some(3)).await?;Sourcepub async fn list_branches(&self) -> Result<HashMap<String, BranchContents>>
pub async fn list_branches(&self) -> Result<HashMap<String, BranchContents>>
List the branches of the table.
Sourcepub async fn delete_branch(&self, name: &str) -> Result<()>
pub async fn delete_branch(&self, name: &str) -> Result<()>
Delete a branch.
Sourcepub async fn diff_branch(&self, from_branch: &str) -> Result<BranchDiff>
pub async fn diff_branch(&self, from_branch: &str) -> Result<BranchDiff>
Diff a branch against main. Remote only.
Sourcepub async fn merge_branch(
&self,
from_branch: &str,
dry_run: bool,
) -> Result<MergeBranchResult>
pub async fn merge_branch( &self, from_branch: &str, dry_run: bool, ) -> Result<MergeBranchResult>
Merge a branch into main, or dry-run. Remote only.
HTTP 409 still returns Ok with MergeBranchStatus::Rejected.
Sourcepub fn current_branch(&self) -> Option<String>
pub fn current_branch(&self) -> Option<String>
The branch this handle is scoped to, or None for main.
Sourcepub async fn stats(&self) -> Result<TableStatistics>
pub async fn stats(&self) -> Result<TableStatistics>
Retrieve statistics on the table
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Table
impl !UnwindSafe for Table
impl Freeze for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<E> ResultError for E
impl<T> ResultType for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.