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 <github@xuanwo.io>
This commit is contained in:
out13
2026-12-01 16:18:03 +08:00
committed by GitHub
co-authored by Xuanwo
parent 0d735c9c46
commit 1e37e8aa0c
7 changed files with 27 additions and 2 deletions
+5
View File
@@ -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<dyn JobHandle>) -> Self {
Self {
inner: JobInner::Handle {
@@ -455,6 +458,7 @@ where
job
}
#[cfg(any(feature = "remote", test))]
pub(crate) fn from_query_task<F, Fut>(
query_id: Uuid,
task: JoinHandle<Result<T>>,
@@ -1172,6 +1176,7 @@ impl SpawnedJob {
Self::new_inner(task, None)
}
#[cfg(any(feature = "remote", test))]
fn new_with_cancellation<T>(
query_id: Uuid,
task: JoinHandle<Result<T>>,
+1
View File
@@ -2068,6 +2068,7 @@ impl RefreshMaterializedViewOptions {
Ok(())
}
#[cfg(feature = "remote")]
pub(crate) fn sql_clause(&self, full: bool) -> Result<String> {
self.validate()?;
let mut values = Vec::new();
+1
View File
@@ -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",
+7 -1
View File
@@ -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<Option<Instant>>);
#[cfg(feature = "remote")]
impl PkFusionMemory {
pub fn learned(&self) -> bool {
self.0
+11 -1
View File
@@ -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<ComputedColumn> {
.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<bool>
/// 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<bool> {
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<String>)],
@@ -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<String>,
+1
View File
@@ -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)]
+1
View File
@@ -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,