From 1e37e8aa0c40dbc7d77dd093e1651fbf0aef6f89 Mon Sep 17 00:00:00 2001 From: out13 Date: Tue, 1 Dec 2026 10:18:03 +0200 Subject: [PATCH] fix: compile lancedb without the remote feature (#4892) ## Problem `cargo clippy --workspace --tests` without the `remote` feature fails under `-D warnings`: a handful of items are reachable only from `remote`-gated modules (or only from tests), so a local-only build reports them as dead code and unused imports. `cargo check -p lancedb --no-default-features` reports the same warnings. ## Fix Gate the remote-only and test-only code behind its feature: - `job.rs`: `TerminalResult::{remote, value, with_value}`, `Job::new`, and the in-process query-task constructors (`from_query_task`, `new_with_cancellation`), which only remote SQL jobs and the job unit tests use, plus the `Uuid` import they need. - `materialized_view.rs`: `RefreshMaterializedViewOptions::sql_clause`, used only to build the remote refresh request. - `query.rs`: `AnalyzePlanDistributedMetrics::as_query_param`. - `query/wal_fusion.rs`: the PK-fusion refusal memory (`PkFusionMemory`, `MEMORY_TTL`) and its `Mutex`, `Duration`, and `Instant` imports. - `table/computed_columns.rs`: the Function declaration planner and its target/plan types (`FunctionApplication`, `FunctionOutputTarget`, `FunctionInputTarget`, `FunctionDeclarationPlan`, `function_input_nullability`, `plan_function_application`). - `table/rte_stats.rs`: `GetRTEStatsResponse`. - `utils`: `resolve_arrow_fts_field_path`. The `TerminalResult::decode` E0599 half this branch originally fixed (constructing `Error::Http` without `remote`) has since landed on `main` separately (#4103, #4233), so the rebase drops that change and keeps only the remaining gating. ## Verification - `cargo check -p lancedb --no-default-features` - `cargo check -p lancedb --features remote` - `cargo clippy -p lancedb --tests --no-default-features -- -D warnings` - `cargo clippy --workspace --tests -- -D warnings` - `cargo fmt --all -- --check` [![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness) Co-authored-by: Xuanwo --- rust/lancedb/src/job.rs | 5 +++++ rust/lancedb/src/materialized_view.rs | 1 + rust/lancedb/src/query.rs | 1 + rust/lancedb/src/query/wal_fusion.rs | 8 +++++++- rust/lancedb/src/table/computed_columns.rs | 12 +++++++++++- rust/lancedb/src/table/rte_stats.rs | 1 + rust/lancedb/src/utils/mod.rs | 1 + 7 files changed, 27 insertions(+), 2 deletions(-) diff --git a/rust/lancedb/src/job.rs b/rust/lancedb/src/job.rs index 5485c8905..f72338cbd 100644 --- a/rust/lancedb/src/job.rs +++ b/rust/lancedb/src/job.rs @@ -222,10 +222,12 @@ impl TerminalResult { } } + #[cfg(feature = "remote")] pub(crate) fn value(&self) -> Option<&Value> { self.value.as_ref() } + #[cfg(feature = "remote")] pub(crate) fn with_value(mut self, value: Value) -> Self { self.value = Some(value); self @@ -362,6 +364,7 @@ impl Job<()> { } } + #[cfg(any(feature = "remote", test))] pub(crate) fn new(handle: Box) -> Self { Self { inner: JobInner::Handle { @@ -455,6 +458,7 @@ where job } + #[cfg(any(feature = "remote", test))] pub(crate) fn from_query_task( query_id: Uuid, task: JoinHandle>, @@ -1172,6 +1176,7 @@ impl SpawnedJob { Self::new_inner(task, None) } + #[cfg(any(feature = "remote", test))] fn new_with_cancellation( query_id: Uuid, task: JoinHandle>, diff --git a/rust/lancedb/src/materialized_view.rs b/rust/lancedb/src/materialized_view.rs index 0591be948..87f73e366 100644 --- a/rust/lancedb/src/materialized_view.rs +++ b/rust/lancedb/src/materialized_view.rs @@ -2068,6 +2068,7 @@ impl RefreshMaterializedViewOptions { Ok(()) } + #[cfg(feature = "remote")] pub(crate) fn sql_clause(&self, full: bool) -> Result { self.validate()?; let mut values = Vec::new(); diff --git a/rust/lancedb/src/query.rs b/rust/lancedb/src/query.rs index 93a026a04..23df1617c 100644 --- a/rust/lancedb/src/query.rs +++ b/rust/lancedb/src/query.rs @@ -713,6 +713,7 @@ pub enum AnalyzePlanDistributedMetrics { } impl AnalyzePlanDistributedMetrics { + #[cfg(feature = "remote")] pub(crate) fn as_query_param(self) -> &'static str { match self { Self::Aggregate => "aggregate", diff --git a/rust/lancedb/src/query/wal_fusion.rs b/rust/lancedb/src/query/wal_fusion.rs index b174e089c..7fdc6788f 100644 --- a/rust/lancedb/src/query/wal_fusion.rs +++ b/rust/lancedb/src/query/wal_fusion.rs @@ -17,7 +17,10 @@ use std::collections::HashMap; use std::future::Future; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; +#[cfg(feature = "remote")] +use std::sync::Mutex; +#[cfg(feature = "remote")] use std::time::{Duration, Instant}; use arrow::row::{RowConverter, SortField}; @@ -104,14 +107,17 @@ where /// stop the memory outliving a write spec someone removed through another /// handle. Being late to notice keeps the query on the primary key, which on a /// base table is still a valid read; the window is what stops that lasting. +#[cfg(feature = "remote")] const MEMORY_TTL: Duration = Duration::from_secs(30); /// A table's memory of having refused `_rowid`, backing /// [`BaseTable::hybrid_pk_fusion_learned`](crate::table::BaseTable::hybrid_pk_fusion_learned) /// for table types that keep one. +#[cfg(feature = "remote")] #[derive(Debug, Default)] pub struct PkFusionMemory(Mutex>); +#[cfg(feature = "remote")] impl PkFusionMemory { pub fn learned(&self) -> bool { self.0 diff --git a/rust/lancedb/src/table/computed_columns.rs b/rust/lancedb/src/table/computed_columns.rs index f64fa4e09..193862b0c 100644 --- a/rust/lancedb/src/table/computed_columns.rs +++ b/rust/lancedb/src/table/computed_columns.rs @@ -40,7 +40,9 @@ use lance_namespace::models::{JsonArrowDataType, JsonArrowField, JsonArrowSchema use serde::{Deserialize, Serialize}; use serde_json::Value; -use crate::function::{FUNCTION_BLOB_V2_TYPE, FunctionApplication, FunctionBinding, OutputMapping}; +#[cfg(any(feature = "remote", test))] +use crate::function::FunctionApplication; +use crate::function::{FUNCTION_BLOB_V2_TYPE, FunctionBinding, OutputMapping}; use crate::materialized_view::without_declarations; use crate::utils::resolve_arrow_field_path; use crate::{Error, Result}; @@ -853,6 +855,7 @@ pub fn computed_columns(schema: &ArrowSchema) -> Vec { .collect() } +#[cfg(any(feature = "remote", test))] #[derive(Debug, Clone, Serialize)] pub(crate) struct FunctionOutputTarget { pub result_field: String, @@ -860,6 +863,7 @@ pub(crate) struct FunctionOutputTarget { pub output_ordinal: u32, } +#[cfg(any(feature = "remote", test))] #[derive(Debug, Clone, Serialize)] pub(crate) struct FunctionInputTarget { pub parameter: String, @@ -868,6 +872,7 @@ pub(crate) struct FunctionInputTarget { pub nullable: bool, } +#[cfg(any(feature = "remote", test))] #[derive(Debug, Clone, Serialize)] pub(crate) struct FunctionDeclarationPlan { pub application: FunctionApplication, @@ -1059,6 +1064,7 @@ pub fn function_input_is_computed(root: &ArrowField, path: &str) -> Result /// Nullability of the parameter a Function input binds: the source field's, /// except that a computed source never passes a null (see /// [`function_input_is_computed`]). +#[cfg(any(feature = "remote", test))] fn function_input_nullability(resolved: &ResolvedFieldPath<'_>, path: &str) -> Result { Ok(!function_input_is_computed(resolved.root, path)? && resolved.leaf.is_nullable()) } @@ -1623,6 +1629,7 @@ fn ensure_binding_matches_schema(schema: &ArrowSchema, binding: &FunctionBinding /// Resolve a Function application against a table schema before any request is /// serialized. Input paths and the complete sibling output schema are fixed in /// one plan. +#[cfg(any(feature = "remote", test))] pub(crate) fn plan_function_application( schema: &ArrowSchema, application: &FunctionApplication, @@ -1635,6 +1642,7 @@ pub(crate) fn plan_function_application( /// All output types are known from the registered signatures. Resolve inputs /// against the complete set so an application can read a later sibling. +#[cfg(any(feature = "remote", test))] pub(crate) fn plan_function_bindings( schema: &ArrowSchema, bindings: &[(FunctionApplication, Option)], @@ -1674,6 +1682,7 @@ pub(crate) fn plan_function_bindings( .collect() } +#[cfg(any(feature = "remote", test))] fn plan_function_outputs( schema: &ArrowSchema, application: &FunctionApplication, @@ -1818,6 +1827,7 @@ fn plan_function_outputs( Ok((outputs, JsonArrowSchema::new(output_fields))) } +#[cfg(any(feature = "remote", test))] fn plan_function_inputs( schema: &ArrowSchema, new_outputs: &HashSet, diff --git a/rust/lancedb/src/table/rte_stats.rs b/rust/lancedb/src/table/rte_stats.rs index 46743be93..cf602e397 100644 --- a/rust/lancedb/src/table/rte_stats.rs +++ b/rust/lancedb/src/table/rte_stats.rs @@ -87,6 +87,7 @@ pub struct RTEStats { /// Server-side JSON envelope for `get_rte_stats`. `rte_stats` is null when /// the table has no RTE write path. +#[cfg(feature = "remote")] #[derive(Debug, Deserialize)] pub(crate) struct GetRTEStatsResponse { #[serde(default)] diff --git a/rust/lancedb/src/utils/mod.rs b/rust/lancedb/src/utils/mod.rs index 86eccb849..43c464047 100644 --- a/rust/lancedb/src/utils/mod.rs +++ b/rust/lancedb/src/utils/mod.rs @@ -525,6 +525,7 @@ pub(crate) fn public_fts_field_path_by_id( }) } +#[cfg(any(feature = "remote", test))] pub(crate) fn resolve_arrow_fts_field_path( schema: &Schema, column: &str,