Implementation:Lance format Lance LanceNamespaceTrait
| Knowledge Sources | |
|---|---|
| Domains | Namespace, Infrastructure |
| Last Updated | 2026-02-08 19:33 GMT |
Overview
Description
The LanceNamespace trait defines the base interface that all Lance namespace implementations must provide. It is an async_trait requiring Send + Sync + Debug, and it declares a comprehensive set of async methods covering namespace management, table lifecycle, data manipulation, indexing, tagging, transactions, and query planning.
Each method has a default implementation that returns Error::NotSupported, allowing backends to incrementally implement only the operations they support. The trait relies on request/response types from the lance_namespace_reqwest_client::models module, which are generated from the Lance Namespace REST specification.
Key method categories:
- Namespace operations --
list_namespaces,describe_namespace,create_namespace,drop_namespace,namespace_exists - Table operations --
list_tables,describe_table,register_table,create_table,drop_table,rename_table,restore_table - Data operations --
insert_into_table,delete_from_table,update_table,merge_insert_into_table,query_table - Index operations --
create_table_index,drop_table_index,list_table_indices - Tag operations --
create_table_tag,update_table_tag,delete_table_tag,list_table_tags - Transaction operations --
alter_transaction,describe_transaction
Usage
Concrete implementations of this trait are provided in the lance-namespace-impls crate (e.g., REST client, local filesystem). The trait is used by higher-level catalog abstractions to manage Lance datasets across various storage backends.
Code Reference
Source Location
rust/lance-namespace/src/namespace.rs
Signature
#[async_trait]
pub trait LanceNamespace: Send + Sync + std::fmt::Debug {
async fn list_namespaces(
&self,
_request: ListNamespacesRequest,
) -> Result<ListNamespacesResponse>;
async fn create_namespace(
&self,
_request: CreateNamespaceRequest,
) -> Result<CreateNamespaceResponse>;
async fn drop_namespace(
&self,
_request: DropNamespaceRequest,
) -> Result<DropNamespaceResponse>;
async fn list_tables(
&self,
_request: ListTablesRequest,
) -> Result<ListTablesResponse>;
async fn create_table(
&self,
_request: CreateTableRequest,
) -> Result<CreateTableResponse>;
async fn query_table(
&self,
_request: QueryTableRequest,
) -> Result<Bytes>;
// ... 30+ additional methods with default NotSupported implementations
}
Import
use lance_namespace::namespace::LanceNamespace;
I/O Contract
Inputs
| Parameter | Type | Description |
|---|---|---|
| request | Various *Request structs |
Operation-specific request objects from lance_namespace_reqwest_client::models
|
Outputs
| Type | Description |
|---|---|
Result<*Response> |
Operation-specific response wrapped in lance_core::Result
|
Result<Bytes> |
Raw byte response for query operations (e.g., Arrow IPC) |
Result<()> |
Success/failure indicator for existence checks |
Usage Examples
use lance_namespace::namespace::LanceNamespace;
use lance_namespace_reqwest_client::models::{
ListNamespacesRequest, CreateNamespaceRequest,
};
async fn example(ns: &dyn LanceNamespace) -> lance_core::Result<()> {
// List child namespaces
let response = ns.list_namespaces(ListNamespacesRequest::default()).await?;
println!("Namespaces: {:?}", response);
// Create a new namespace
let create_req = CreateNamespaceRequest { /* ... */ };
let created = ns.create_namespace(create_req).await?;
Ok(())
}
Related Pages
- Lance_format_Lance_NamespaceError -- Error types returned by namespace operations
- Lance_format_Lance_NamespaceSchema -- Schema conversion used by table operations
- Lance_format_Lance_RestApi -- REST specification that mirrors this trait's operations