diff --git a/python/src/connection.rs b/python/src/connection.rs index a9ec8e537..9c67f38c7 100644 --- a/python/src/connection.rs +++ b/python/src/connection.rs @@ -10,7 +10,7 @@ use std::{ use arrow::{datatypes::Schema, ffi_stream::ArrowArrayStreamReader, pyarrow::FromPyArrow}; use lancedb::{ connection::Connection as LanceConnection, - connection::PushdownOperation, + connection::NamespaceClientPushdownOperation, database::namespace::LanceNamespaceDatabase, database::{CreateTableMode, Database, ReadConsistency}, }; @@ -45,17 +45,17 @@ impl Connection { } } -fn parse_pushdown_operations( +fn parse_namespace_client_pushdown_operations( operations: Option>, -) -> PyResult> { +) -> PyResult> { let mut parsed = HashSet::new(); for operation in operations.unwrap_or_default() { match operation.as_str() { "QueryTable" => { - parsed.insert(PushdownOperation::QueryTable); + parsed.insert(NamespaceClientPushdownOperation::QueryTable); } "CreateTable" => { - parsed.insert(PushdownOperation::CreateTable); + parsed.insert(NamespaceClientPushdownOperation::CreateTable); } _ => { return Err(PyValueError::new_err(format!( @@ -590,7 +590,8 @@ pub fn connect_namespace_client( ) -> PyResult { let namespace_client = extract_namespace_arc(py, namespace_client)?; let read_consistency_interval = read_consistency_interval.map(Duration::from_secs_f64); - let pushdown_operations = parse_pushdown_operations(namespace_client_pushdown_operations)?; + let namespace_client_pushdown_operations = + parse_namespace_client_pushdown_operations(namespace_client_pushdown_operations)?; let ns_impl = namespace_client_impl.unwrap_or_else(|| "python".to_string()); let ns_properties = namespace_client_properties.unwrap_or_default(); let storage_options = storage_options.unwrap_or_default(); @@ -603,7 +604,7 @@ pub fn connect_namespace_client( storage_options, read_consistency_interval, session, - pushdown_operations, + namespace_client_pushdown_operations, ); Ok(Connection::new(LanceConnection::new( diff --git a/rust/lancedb/src/connection.rs b/rust/lancedb/src/connection.rs index 35863aa60..9e0d3ea3f 100644 --- a/rust/lancedb/src/connection.rs +++ b/rust/lancedb/src/connection.rs @@ -915,7 +915,7 @@ use std::collections::HashSet; /// These operations will be executed on the namespace server instead of locally /// when enabled via [`ConnectNamespaceBuilder::pushdown_operations`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum PushdownOperation { +pub enum NamespaceClientPushdownOperation { /// Execute queries on the namespace server via `query_table()` instead of locally. QueryTable, /// Execute table creation on the namespace server via `create_table()` @@ -931,7 +931,7 @@ pub struct ConnectNamespaceBuilder { read_consistency_interval: Option, embedding_registry: Option>, session: Option>, - pushdown_operations: HashSet, + pushdown_operations: HashSet, } impl ConnectNamespaceBuilder { @@ -1029,11 +1029,11 @@ impl ConnectNamespaceBuilder { /// and leveraging server-side compute resources. /// /// Available operations: - /// - [`PushdownOperation::QueryTable`]: Execute queries via `namespace.query_table()` - /// - [`PushdownOperation::CreateTable`]: Execute table creation via `namespace.create_table()` + /// - [`NamespaceClientPushdownOperation::QueryTable`]: Execute queries via `namespace.query_table()` + /// - [`NamespaceClientPushdownOperation::CreateTable`]: Execute table creation via `namespace.create_table()` /// /// By default, no operations are pushed down (all executed locally). - pub fn pushdown_operation(mut self, operation: PushdownOperation) -> Self { + pub fn pushdown_operation(mut self, operation: NamespaceClientPushdownOperation) -> Self { self.pushdown_operations.insert(operation); self } @@ -1043,7 +1043,7 @@ impl ConnectNamespaceBuilder { /// See [`Self::pushdown_operation`] for details. pub fn pushdown_operations( mut self, - operations: impl IntoIterator, + operations: impl IntoIterator, ) -> Self { self.pushdown_operations.extend(operations); self diff --git a/rust/lancedb/src/database/namespace.rs b/rust/lancedb/src/database/namespace.rs index 13a8e3967..1473315b7 100644 --- a/rust/lancedb/src/database/namespace.rs +++ b/rust/lancedb/src/database/namespace.rs @@ -22,7 +22,7 @@ use lance_namespace_impls::ConnectBuilder; use lance_table::io::commit::CommitHandler; use lance_table::io::commit::external_manifest::ExternalManifestCommitHandler; -use crate::connection::PushdownOperation; +use crate::connection::NamespaceClientPushdownOperation; use crate::database::ReadConsistency; use crate::error::{Error, Result}; use crate::table::NativeTable; @@ -44,7 +44,7 @@ pub struct LanceNamespaceDatabase { // database URI uri: String, // Operations to push down to the namespace server - pushdown_operations: HashSet, + pushdown_operations: HashSet, // Namespace implementation type (e.g., "dir", "rest") ns_impl: String, // Namespace properties used to construct the namespace client @@ -53,23 +53,23 @@ pub struct LanceNamespaceDatabase { impl LanceNamespaceDatabase { pub fn from_namespace_client( - namespace: Arc, - ns_impl: String, - ns_properties: HashMap, + namespace_client: Arc, + namespace_client_impl: String, + namespace_client_properties: HashMap, storage_options: HashMap, read_consistency_interval: Option, session: Option>, - pushdown_operations: HashSet, + namespace_client_pushdown_operations: HashSet, ) -> Self { Self { - namespace, + namespace: namespace_client, storage_options, read_consistency_interval, session, - uri: format!("namespace://{}", ns_impl), - pushdown_operations, - ns_impl, - ns_properties, + uri: format!("namespace://{}", namespace_client_impl), + pushdown_operations: namespace_client_pushdown_operations, + ns_impl: namespace_client_impl, + ns_properties: namespace_client_properties, } } @@ -79,7 +79,7 @@ impl LanceNamespaceDatabase { storage_options: HashMap, read_consistency_interval: Option, session: Option>, - pushdown_operations: HashSet, + pushdown_operations: HashSet, ) -> Result { let mut builder = ConnectBuilder::new(ns_impl); for (key, value) in ns_properties.clone() { diff --git a/rust/lancedb/src/table.rs b/rust/lancedb/src/table.rs index b83a880be..73415e89b 100644 --- a/rust/lancedb/src/table.rs +++ b/rust/lancedb/src/table.rs @@ -47,7 +47,7 @@ use std::format; use std::path::Path; use std::sync::Arc; -use crate::connection::PushdownOperation; +use crate::connection::NamespaceClientPushdownOperation; use crate::data::scannable::{PeekedScannable, Scannable, estimate_write_partitions}; use crate::database::Database; @@ -1272,7 +1272,7 @@ pub struct NativeTable { pub(crate) namespace_client: Option>, // Operations to push down to the namespace server. // pub(crate) so query.rs can access the field for server-side query execution. - pub(crate) pushdown_operations: HashSet, + pub(crate) pushdown_operations: HashSet, } impl std::fmt::Debug for NativeTable { @@ -1359,7 +1359,7 @@ impl NativeTable { params: Option, read_consistency_interval: Option, namespace_client: Option>, - pushdown_operations: HashSet, + pushdown_operations: HashSet, managed_versioning: Option, ) -> Result { let params = params.unwrap_or_default(); @@ -1470,7 +1470,7 @@ impl NativeTable { write_store_wrapper: Option>, params: Option, read_consistency_interval: Option, - pushdown_operations: HashSet, + pushdown_operations: HashSet, session: Option>, ) -> Result { let mut params = params.unwrap_or_default(); @@ -1518,7 +1518,7 @@ impl NativeTable { let id = Self::build_id(&namespace, name); let stored_namespace_client = - if pushdown_operations.contains(&PushdownOperation::QueryTable) { + if pushdown_operations.contains(&NamespaceClientPushdownOperation::QueryTable) { Some(namespace_client) } else { None @@ -1588,7 +1588,7 @@ impl NativeTable { params: Option, read_consistency_interval: Option, namespace_client: Option>, - pushdown_operations: HashSet, + pushdown_operations: HashSet, ) -> Result { // Default params uses format v1. let params = params.unwrap_or(WriteParams { @@ -1635,7 +1635,7 @@ impl NativeTable { params: Option, read_consistency_interval: Option, namespace_client: Option>, - pushdown_operations: HashSet, + pushdown_operations: HashSet, ) -> Result { let data: Box = Box::new(RecordBatch::new_empty(schema)); Self::create( @@ -1685,7 +1685,7 @@ impl NativeTable { write_store_wrapper: Option>, params: Option, read_consistency_interval: Option, - pushdown_operations: HashSet, + pushdown_operations: HashSet, session: Option>, ) -> Result { // Build table_id from namespace + name for the storage options provider @@ -1738,7 +1738,7 @@ impl NativeTable { let id = Self::build_id(&namespace, name); let stored_namespace_client = - if pushdown_operations.contains(&PushdownOperation::QueryTable) { + if pushdown_operations.contains(&NamespaceClientPushdownOperation::QueryTable) { Some(namespace_client) } else { None diff --git a/rust/lancedb/src/table/query.rs b/rust/lancedb/src/table/query.rs index ae6a8cd08..e7e66a901 100644 --- a/rust/lancedb/src/table/query.rs +++ b/rust/lancedb/src/table/query.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use super::NativeTable; -use crate::connection::PushdownOperation; +use crate::connection::NamespaceClientPushdownOperation; use crate::error::{Error, Result}; use crate::expr::expr_to_sql_string; use crate::query::{ @@ -44,7 +44,7 @@ pub async fn execute_query( // If QueryTable pushdown is enabled and namespace client is configured, use server-side query execution if table .pushdown_operations - .contains(&PushdownOperation::QueryTable) + .contains(&NamespaceClientPushdownOperation::QueryTable) && let Some(ref namespace_client) = table.namespace_client { return execute_namespace_query(table, namespace_client.clone(), query, options).await;