## Summary
- Rust remote connect reads `LANCEDB_API_KEY` when a `db://` connection
has no `api_key` and no `oauth_config`. Python already does this in its
own wrapper; Node and Rust callers did not.
- An explicit API key still wins. An empty `LANCEDB_API_KEY` is treated
as present, matching Python's `is None` check, and the connection sends
no `x-api-key` header.
- OAuth does not read the variable, so an ambient key cannot turn an
OAuth connect into an invalid API-key-plus-OAuth configuration. The
fallback lives in Rust `execute_remote`, so Node does not write the
credential into the caller's options object.
Supersedes #3797, which is stale and conflicting. This addresses the
Gatekeeper requests there: do not apply the environment key when
`oauthConfig` is set, and do not write it into the caller-owned options.
## Test plan
- [x] `cargo test --features remote -p lancedb --lib connection::` (each
env case re-runs the test binary as a child process with
`LANCEDB_API_KEY` set or removed on the child `Command`; no in-process
`set_var`/`remove_var`)
- [x] `cargo clippy -p lancedb --all-targets --features remote -- -D
warnings`
- [x] `cargo fmt --all -- --check`
- [x] `cd nodejs && pnpm build`
- [x] `cd nodejs && pnpm exec jest __test__/remote_api_key_env.test.ts`
(env set only in a child process; missing-key case asserts `connect()`
itself rejects against the loopback endpoint; OAuth case asserts
`x-api-key` is absent)
- [x] `cd nodejs && pnpm lint-ci`; `pnpm run docs` leaves `docs/src/js`
unchanged
Written with Cursor (Grok).
---------
Co-authored-by: Preston Zhao <195942578+canyang25@users.noreply.github.com>
Co-authored-by: Xuanwo <github@xuanwo.io>
## Summary
Function registration uses Flight SQL. If the SDK has no usable SQL URI
or cannot establish a connection, it points to the cluster’s published
Flight SQL URI and the Public SQL or PrivateLink SQL settings. The
diagnostic retains the original exception type, cause text, and request
ID when present.
## Validation
- Built main (`0abc7d48`) and the SDK change (`4bfdbb217`) in the same
isolated Linux VM with the locked Python environment. The final commit
updates only the test assertion for platform-dependent connection
errors.
- Compared 22 calls against a healthy HTTPS REST fixture and Flight
endpoints. The expected five registration failures gained the hint.
After accounting for request IDs, all original errors and successful
results matched.
- New regression tests on main had two expected failures and three
passing controls. The SDK change passed 86 tests with 16 skipped across
registration, Function catalog, SQL, and view creation. Rust formatting
and Ruff passed.
- All 50 GitHub checks passed on `7c2dad8bc`, including the [Python
workflow](https://github.com/lancedb/lancedb/actions/runs/46796061600)
and the [Rust macOS 26
rerun](https://github.com/lancedb/lancedb/actions/runs/46796061943/job/143185732469).
Closes#5340.
Reject `CombinedFields` before sending an FTS query to a LanceDB
Enterprise server older than 0.3.0. The check follows all Boolean
clauses and both sides of a Boost query. The 0.3.0 regression test also
checks that unequal column weights and the `AND` operator reach the
server.
Reproduced with Python SDK 0.42.1 against a mock 0.2.0 server. Both
searches returned HTTP 200. The top-level query lost its weights and
operator, and the nested Boolean query sent an empty string. The same
searches preserved the structured query on 0.3.0.
This adds a `.progress()` option to `IndexBuilder` and plumbs it through
`create_index` to the lance `CreateIndexBuilder`.
There was already a progress callback usable with `table.optimize()` via
`OptimizeOptions`, but it was not exposed for `table.create_index()`,
although the underlying lance methods support it.
An indexed cosine query with an unindexed tail can lose valid rows when
its distance range has a positive lower bound. Lance now translates the
candidate bounds for exact rescoring. Replanning the ANN branch with
doubled inputs can translate them a second time. A public range of
`[0.10, 0.16)` then reaches the index as `[0.40, 0.64)`.
The SDK checks the candidate bounds on each quantized cosine ANN node.
If Lance already supplied the normalized squared-L2 bounds, the SDK uses
that node. Exact fallback and refinement keep their original range, and
returned distances use the public cosine scale.
The regression compares indexed results against a brute-force scan after
appending an out-of-range vector. It exercises modern and legacy IVF_PQ,
single-query refinement, and modern batched queries with and without
refinement. Rust formatting and whitespace checks passed. Project CI
runs the behavioral tests.
Refs #4371
The link checker flags
`https://docs.lancedb.com/performance#compaction-and-cleanup` because
that section no longer exists. Compaction has its own page now, and its
"When to run it" section (`#when`) covers the warning this link is
attached to: tables with many small fragments.
This points `DocLink::Compaction` at `/maintenance/compaction#when` and
updates the two tests that hard-code the URL. The anchor exists on the
published site and in `docs/web/maintenance/compaction.mdx`, so
`test_all_doc_links_resolve_in_repo_docs` still holds.
Tests: `python -m unittest ci.tests.test_extract_sdk_doc_links` and
`cargo test -p lancedb --lib docs::tests::` pass locally.
Co-authored-by: Xuanwo <github@xuanwo.io>
`create_table` with `CreateTableMode::ExistOk` treated any successful
`describe_table` as an existing table and tried to open it. A table that
was only declared in the namespace (no data on storage yet) failed with
`TableNotFound ... DatasetNotFound ... _versions`, while `Create` mode
already handles this case.
- Ask `describe_table` for `check_declared`, and only open the table
when `is_only_declared` is not true.
- Otherwise fall through to the normal create path, and handle a declare
conflict for `ExistOk` the same way as for `Create`.
Test: `test_namespace_create_table_exist_ok_after_declare_only` fails on
main with `TableNotFound { name: "declared_only", ... _versions }` and
passes with this change. The existing `exist_ok` tests are unchanged and
pass.
The race between `describe_table` and `declare_table` is unchanged by
this PR.
## Summary
Callers that consume every selected hit can relax the final output order
with `ordered_results(false)` in Rust, `ordered_results(False)` in
Python, or `orderedResults(false)` in TypeScript. Ranked output remains
the default. The option preserves top-k selection, each hit’s score and
projected columns, and the existing rules for ties at the cutoff.
Embedded passes eligible queries to the Lance scanner. Enterprise sends
`"ordered": false` for eligible searches and omits the field by default.
Explicit sorting, positive offsets, batch vector queries and inputs to
hybrid fusion or reranking keep their existing order.
## Validation
A managed Linux preview passed 8 Rust wire cases, 4 Embedded Python
cases, 10 HTTP mock cases and all 52 TypeScript query tests. The preview
used a candidate Lance revision. Project CI on this PR validates the
integration with the official Lance `v16.0.0-beta.6`.
Uses the official Lance dependency from #5327, now merged into `main`.
BREAKING CHANGE: Callers that initialize `VectorQueryRequest` with an
exhaustive struct literal must add `query_parallelism: None` to preserve
automatic scheduling.
Expose Lance's existing IVF partition-search concurrency control through
the Rust `VectorQuery::query_parallelism` builder. This lets callers
override the automatic sequential policy used by flat sub-indexes
without changing the probe budget or bypassing LanceDB's query API.
The setting is optional, so existing queries keep their behavior.
Accepted values match Lance: `0` for automatic selection, `-1` for the
CPU pool, `1` for sequential execution, and positive limits for
partition-parallel execution. Values below `-1` are rejected, including
requests constructed directly through public fields.
An ordinary Embedded IVF query applies the setting within each index
segment. Separate segments may run concurrently. If the selected plan
uses shared batch IVF, an explicit value returns `NotSupported` because
its scheduler controls its own load and scoring windows. Leaving it
unset preserves batch execution. Enterprise also returns `NotSupported`
before sending an explicitly configured query because its request
contract does not support this setting. Namespace queries with explicit
settings route locally. The existing ordering, scan-order and RTE checks
remain in effect.
The tests cover single-segment IVF values and result equivalence,
two-vector Embedded batch execution with the option unset and rejected
explicit settings, Enterprise default requests and rejection before HTTP
for explicit settings, direct invalid requests, and namespace/RTE
routing. The Rust API and vector-search guide document the per-segment
scope.
Lance already exposes this control (introduced in
https://github.com/lance-format/lance/pull/6475); this PR exposes it at
the LanceDB Rust layer.
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
Add rerank_vector() and rerank_fts() methods to Reranker trait, allowing
rerankers to work with single search modes instead of only hybrid
search.
Implemented for:
- RRFReranker (Rust and Python)
- LinearCombinationReranker (Python)
Resolves TODO at rust/lancedb/src/rerankers.rs:55
Changes:
- Extended Reranker trait with default implementations
- Added unit tests for new methods
- Updated documentation with examples
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
LanceNamespaceDatabase::create_table previously ignored the
OpenTableRequest callback and bypassed schema validation when
CreateTableMode::ExistOk matched an existing table.
- Invoke (callback)(OpenTableRequest) and open via self.open_table(req)
so caller-supplied namespace open options (name, namespace_path,
lance_read_params) are applied.
- Compare the existing table schema against the incoming schema using
lance_core::datatypes::Schema persistence rules (compare_with_options)
and return Error::Schema ("Provided schema does not match existing table
schema") on mismatch.
- Add unit tests in database::namespace::tests covering
callback-selected table opening, FixedSizeList persistence
compatibility, and mismatched schemas for both create_table and
create_empty_table.
Closes https://github.com/lancedb/lancedb/issues/5123
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
## 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://github.com/deepseek-ai/deepseek-harness)
Co-authored-by: Xuanwo <github@xuanwo.io>
## Why
Lance stores a fixed-size list of a primitive type without its child
field and reads the child back as a nullable `item`. It also stores
`Utf8View`/`BinaryView` as `Utf8`/`Binary`. A schema such as
`DataType::new_fixed_size_list(DataType::Float32, n, false)` therefore
never equals the stored schema. In Python, Rust and TypeScript,
`exist_ok` fails with "Provided schema does not match existing table
schema" on every run after the first.
Part of #2570. This fixes reopening an existing table with `exist_ok`
and the original schema. The first create still normalizes the child
field, so `table.schema()` returns Lance's schema and the issue's
`assert_eq!(table.schema(), schema)` still differs.
## What changed
- `ListingDatabase::handle_table_exists` keeps the exact comparison. It
also accepts a provided schema that converts through
`lance::datatypes::Schema` to the table's schema, which is the same
conversion `NativeTable::schema` uses. A schema Lance can't convert
still returns `Error::Schema`.
- The reopen now passes the create request's `location` into
`OpenTableRequest` before the `exist_ok` callback runs. It used to open
the default location, so `create_table(..., exist_ok, location)` could
return a different table with the same name.
- Out of scope: the remote client's `exist_ok` fallback (`remote/db.rs`)
has the same strict `!=`. Whether it triggers depends on what the
server's describe returns, so I left it unchanged.
## Verification
- `test_create_table_exist_ok_with_lance_normalized_type` covers an FSL
with a non-null child, an FSL whose child is named `element`, and
`Utf8View`. A real difference (top-level nullability) still fails with
`Error::Schema`.
- `test_create_table_exist_ok_opens_requested_location` puts `id=10` at
the default location and `id=20` at an explicit one. With the original
and with the normalized schema, `exist_ok` with the explicit location
must return that URI and read back `id=20`.
- Each test fails without its fix and passes with it. `cargo test -p
lancedb --lib` (2383 passed), `cargo clippy -p lancedb --tests -- -D
warnings`, `cargo fmt --check` and typos are clean. The Python bindings
are unchanged, and `python/tests/test_db.py` was not run locally.
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
The deferred-result timeout regression intermittently fails in the macOS
SDK SQL job. The test pauses Tokio while opening a loopback DoGet, so
the SDK deadline and the gRPC request timer can compete to finish the
read. [Failure on
main](https://github.com/lancedb/lancedb/actions/runs/46420851203/job/141855322793)
Delay result-request headers so the SDK deadline expires before DoGet
starts. The regression checks that the pending reader returns the
overall timeout and that the Flight server receives cancellation. The
timeout assertion also reports the unexpected result on failure.
Fixes#4754
Add wand_factor support across synchronous and asynchronous FTS and
hybrid query APIs, with finite non-negative value validation, PyO3
propagation, query serialization support, and namespace execution
fallback when a custom factor is configured. Add tests covering default
behavior, custom values, validation, clearing the factor, sync/async
execution, serialization round-trips, and namespace routing.
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
resolves#4258
## Summary
- document how indexed partial-column merges patch columns across
touched fragments
- explain how full-scan merges rewrite rows and can materialize the
target table
- describe the index-coverage, batching, and memory tradeoffs
- align the Python, Rust, and TypeScript `use_index` API documentation
## Verification
- `git diff --check`
- Ruff 0.15.20 formatting check for `python/python/lancedb/merge.py`
- Biome 1.9.4 check for `nodejs/lancedb/merge.ts`
- reviewed the rendered MDX structure and cross-SDK wording
The TypeDoc generation command was also attempted. It cannot complete in
this checkout because the Rust-generated `nodejs/lancedb/native.d.ts`
artifact is absent and Rust tooling is not installed; TypeDoc stops on
the resulting pre-existing module-resolution errors before generating
output.
---------
Signed-off-by: Himanshu S <me.mrhimanshu@gmail.com>
Co-authored-by: Himanshu <18554133+mrhimanshu@users.noreply.github.com>
Co-authored-by: Himanshu S <me.mrhimanshu@gmail.com>
BREAKING CHANGE: Older Enterprise index listings that require per-index
statistics now omit historical entries with empty names, `.` or `..`.
Remote index operations reject these unaddressable names. Operators
needing to remove such entries can use server-side maintenance; direct
native access also supports cleanup. Ordinary index names and
`exist_ok=True` reuse require no migration.
Fixes#5007
Remote index URLs previously allowed `.` and `..` as path segments.
Reqwest normalizes them, so dropping an index named `..` could send the
table-level drop request and delete the table.
Guard the remote statistics, prewarm, and drop routes against empty
names, `.` and `..`, then percent-encode all other names. Index creation
retains its existing name policy on both backends, including names such
as `Customer lookup` and `café_idx` and reuse through `exist_ok=True`.
The same remote guard applies on checked-out branches.
Enriched Enterprise listings retain these entries without issuing stats
requests. Native cleanup is covered by a regression test. API
documentation explains these limits, and website release guidance
remains a non-rendering draft.
Validation:
- Before the review fix, 12 of 15 focused regressions failed,
reproducing valid-name rejection, generated-name reuse failure, and
mixed legacy-list failure.
- 60 focused Rust tests passed, covering unsafe routes, encoded names,
mixed legacy/enriched listings, generated names, native and Enterprise
lifecycles, checked-out branches, and `exist_ok` preservation of index
identity, definition, and table version.
- Rebuilt the Python extension in the uv-managed environment from
`python/uv.lock`; all 28 targeted Python tests passed, including both
names and synchronous/asynchronous `exist_ok` reuse.
- Node native build, TypeScript type checking, lint/format checks, four
targeted index tests, and generated API documentation passed.
- Rust formatting, Clippy (`remote`, tests and examples), Python
formatting/lint, repository-wide Typos 1.26.0, and `git diff --check`
passed. Native builds used the repository `ci` profile with
`remote,lancedb/metrics-otel` enabled for Python and Node.
- Repository-root Ruff lint reports 59 existing errors in unchanged
`docs/web-tests`; Python-package lint passes.
<!-- lance-gatekeeper-fix:v1 agent=1ef05de7bc00306ccd6f8a60b9a81003
generation=1 -->
<!-- gatefixer-walkthrough:v1
head=6b25e10810ea1d11a4ef56be63c4ef50225f65d6 -->
## Change walkthrough
```mermaid
flowchart TD
entry["Listed index"] --> typed{"Type available?"}
typed -->|Yes| include["Include index"]
typed -->|No| safe{"Addressable name?"}
safe -->|No| omit["Omit entry"]
safe -->|Yes| stats["Encode and fetch stats"]
stats --> include
```
Creation preserves existing name support; remote routes reject only
empty names, `.` and `..`.
**Read:** [Route
guard](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/remote/table.rs#L102-L112)
→ [Listing
fallback](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/remote/table.rs#L2534-L2596)
→ [Index-preservation
regression](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/table/create_index.rs#L1431-L1481).
<sub>Snapshot:
[6b25e10](https://github.com/lancedb/lancedb/commit/6b25e10810ea1d11a4ef56be63c4ef50225f65d6)</sub>
<!-- gatefixer-walkthrough:end -->
---------
Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
Python callers can pass a `datetime` to `Table.checkout()` and
`AsyncTable.checkout()` to read several tables as of a single cutoff.
Each table is pinned to the highest retained version on its current
branch whose reported commit timestamp is at or before the cutoff. A
cutoff before all retained versions raises `ValueError`.
The Rust `Table::checkout_as_of` method scans the branch's retained
history and compares the commit timestamps at the precision supplied by
the backend. On Embedded it resolves and checks out the version on the
same dataset. If a concurrent tag checkout moves the handle to another
branch, it retries there before pinning the handle. On Enterprise it
follows all version-history pages on the same branch before checking out
the selected version. Servers that report only whole milliseconds can
group commits on opposite sides of a cutoff. For an exact reread, record
both the branch and version of each input after checkout, then reopen
the table with both values. Python interprets naive datetimes in the
system's local time zone and honors explicit UTC offsets.
The website guide includes a draft paragraph for the SDK release.
Closes#2293.
## Validation
- Built the Windows x64 native extension from this checkout with the
repository's `ci` profile and CPython 3.12.
- `test_table.py` passed 558 tests with 20 skips. `test_remote_db.py`
passed 759 tests with 2 skips using its HTTP test server.
- The new tests cover two tables at one cutoff, pinning after later
writes, recovery with `checkout_latest()`, a cutoff before the first
version, non-UTC input, tied commits, and a commit one nanosecond past
the cutoff. All three also passed with `TZ=EST5EDT`.
- A real Embedded handle switching branches during timestamp lookup
selected the wrong branch version in 40/40 attempts before the
concurrency fix and the expected version in 40/40 attempts afterward.
The Rust regression test forces that interleaving with a
filesystem-backed table.
- A two-page Enterprise HTTP fixture reproduced checkout at v1 with the
previous SDK and confirmed checkout at v2 after the fix. The Rust
regression asserts the branch and continuation token on page two and
reads back the pinned version. A separate test covers empty intermediate
pages and repeated tokens.
- Both Rust branch checkout tests and the `Table::checkout_as_of`
doctest passed with the `remote` feature enabled.
- Python SDK Ruff checks and formatting, Pyright, Rust formatting, and
Vale passed. Repository-wide Ruff reports 59 existing diagnostics in the
unchanged `docs/web-tests` files.
---------
Co-authored-by: lipeih <lipeihan@eazytec.com>
Fixes#5222
## Summary
Embedded vector and full-text searches rejected `IN (SELECT ...)`
because Lance's scanner parsed the filter as a single-table expression.
A team-scoped search with `limit(1)` needs to rank eligible documents
using keys from the sharing table.
Resolve unqualified lookup tables through the originating database and
use DataFusion to evaluate the predicate on the search snapshot. Pass
the matching row IDs to Lance before ranking. The syntax applies to
base-table prefilters within one namespace. Literal filters use the
existing scanner path.
## Tests
Tests: `/bin/sh -c 'cd nodejs && corepack pnpm test --runInBand
__test__/query.test.ts -t '"'"'prefilters by keys from another
table'"'"''`.
Result: cd nodejs && corepack pnpm test --runInBand
__test__/query.test.ts on the exact-HEAD published native binary before
adding tests: 41 passed.
Result: cd nodejs && corepack pnpm test --runInBand
__test__/query.test.ts -t 'prefilters by keys from another table' on the
exact-HEAD published native binary: 2 failed with the reported
unsupported SQL expression, exit 1 (OSSCOUT_BASE.log).
Result: cd nodejs && corepack pnpm lint: passed after correcting new
fixture key style.
Result: cargo fmt --all && git diff --check: passed.
Result: cd nodejs && corepack pnpm test --runInBand --runTestsByPath
__test__/expr.test.ts __test__/remote.test.ts on the exact-HEAD
published native binary: 179 passed across 2 suites.
Result: cd nodejs && corepack pnpm tsc && corepack pnpm run docs with
the exact-HEAD native declarations: passed, with no generated
documentation changes.
Result: cd nodejs && corepack pnpm build:debug --profile ci && corepack
pnpm tsc: passed from the patched source.
Result: cd nodejs && corepack pnpm test --runInBand
__test__/query.test.ts -t 'prefilters by keys from another table' on the
source-built patch: 2 passed, exit 0 (OSSCOUT_PATCHED.log).
Result: cd nodejs && corepack pnpm test --runInBand --runTestsByPath
__test__/query.test.ts __test__/expr.test.ts __test__/remote.test.ts on
the source-built patch: 225 passed across 3 suites, exit 0
(OSSCOUT_PATCHED.log).
Result: cd nodejs && corepack pnpm run docs on the source-built patch:
passed, with no generated documentation changes.
Regression coverage: `nodejs/__test__/query.test.ts`.
<!-- oss-scout-job:job-2628acdb-66f3-4d91-8a6e-d5d15e92bde7 -->
---------
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
Fixes#5133
## What changed
Use Lance's scalar training requests to validate resolved Arrow fields
and share the same Auto index selection across Embedded and Enterprise.
Auto chooses IVF_PQ for vector fields and BTree for supported scalar
fields.
## Why
LanceDB's copied type lists rejected Binary, LargeBinary, and LargeUtf8
fields that Lance can index. Explicit and automatic BTree creation now
accept those fields. BTree and ZoneMap retain a targeted guard on the
Arrow Null type because the pinned Lance build drops IS NULL matches
after either index is created. FTS and Bitmap continue to check the
relevant Arrow extension metadata.
Refs #5133.
## How it was tested
Tests: `cargo test --profile ci --locked --features remote -p lancedb
--lib table::create_index::tests::test_create_btree_on_binary --
--exact`.
Result: cargo test --profile ci --locked --features remote -p lancedb
--lib table::create_index::tests::test_create_btree_on_binary -- --exact
(base): expected failure, 0 passed and 1 failed, exit 101.
Result: cargo test --profile ci --locked --features remote -p lancedb
--lib table::create_index::tests:: (base): 28 existing cases passed, and
only the new regression failed, exit 101.
Result: target/ci/deps/lancedb-bb9dc6b24005d6a0
remote::table::tests::test_create_index
remote::table::tests::test_create_list_element_fts_requires_server_support
remote::table::tests::test_branch_create_index
utils::tests::test_fts_field_logical_type_validation (base binary): 14
passed, exit 0.
Result: cargo test --profile ci --locked --features remote -p lancedb
--lib --no-run (patched): an initial build exposed missing Enterprise
imports, which were restored before a successful rebuild.
Result: cargo test --profile ci --locked --features remote -p lancedb
--lib table::create_index::tests::test_create_btree_on_binary -- --exact
(patched): 1 passed, 0 failed, exit 0 in both runs.
Result: cargo test --profile ci --locked --features remote -p lancedb
--lib -- table::create_index::tests::
remote::table::tests::test_create_index
remote::table::tests::test_create_list_element_fts_requires_server_support
remote::table::tests::test_branch_create_index
remote::table::tests::test_list_indices_fts_public_list_path
remote::table::tests::test_list_indices_nested_field_paths
index::tests:: utils::tests:: (patched): 61 passed, 0 failed, exit 0.
Result: LANCE_FTS_FORMAT_VERSION=bad cargo test --profile ci --locked
--features remote -p lancedb --lib
utils::tests::test_fts_field_logical_type_validation -- --exact
(patched): 1 passed, 0 failed, exit 0.
Result: /tmp/osscout-candidate/null-probe (direct probe using the pinned
Lance build): IS NULL matched 2 rows before indexing, 0 after building a
BTree or ZoneMap, and 2 after building a Bitmap.
Result: cargo fmt --all -- --check and git diff --check passed.
Regression coverage: `rust/lancedb/src/table/create_index.rs`.
<!-- oss-scout-job:job-aa1c056f-6c0a-4141-adae-fe30d5ef896a -->
---------
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
Closes#1101.
Rust users currently have to build `RecordBatch`es by hand to write to a
table, and read results back as Arrow arrays. This adds an optional
`serde` feature, built on `serde_arrow` (`arrow-59`, matching our arrow
line), laid out like the `polars` feature:
- `lancedb::arrow::from_structs(&[T]) -> Result<RecordBatch>` derives
the schema from `T`. Strings, lists and binaries use the 32-bit offset
types (`Utf8`, `List`, `Binary`) rather than `serde_arrow`'s `Large*`
defaults.
- `lancedb::arrow::from_structs_with_schema(&[T], SchemaRef)` serializes
against an explicit schema and keeps its metadata.
- `lancedb::arrow::IntoStructs` adds `into_structs::<T>()` on
`SendableRecordBatchStream`, mirroring `IntoPolars`. `serde_arrow` must
be able to read every selected column, and `T`'s Serde rules then apply
(derived `Deserialize` ignores extra readable columns such as
`_distance`, while `QueryBase::select` can project only the needed
columns).
Both functions return a `RecordBatch`, which is already `Scannable`, so
`add` and `create_table` need no changes. A wrapper type implementing
`Scannable` would have to convert inside `schema()`, which can't return
an error.
One caveat, covered in the docs and the example: serde has no fixed-size
sequence type that maps to Arrow, so `Vec<f32>` traces to
`List<Float32>` and `[f32; N]` traces to a struct. Appending to an
existing table works because the write path casts to the table's
`FixedSizeList` column. Creating a table from a traced batch leaves the
vector column as a `List`, so it can't be searched;
`from_structs_with_schema` is the way to create tables with vectors.
Happy to add a vector-column shorthand instead if you'd prefer that API.
`serde_arrow` and its `marrow` dependency are MIT. The `arrow-59`
feature will need bumping with the workspace arrow version, the same as
the `polars` pin.
Testing:
- Unit tests in `arrow::serde_tests`: traced schema types, empty input,
metadata preserved, wrong vector dimension error, add + read-back round
trip including nested struct and `Option` fields, create + vector search
into structs with `_distance`, missing column error, `Select::columns`
projection (including non-UTC timestamp exclusion and
`#[serde(deny_unknown_fields)]`).
- Doctests for all three APIs, and `examples/serde.rs`.
- `cargo fmt --all -- --check`
- `cargo test -p lancedb --features serde --locked --lib serde_tests`
and `--doc arrow::`
BREAKING CHANGE: `Permutation.__getitem__` now returns a single row instead of a one-element list for list-producing formats (such as the default `"python"` format), so callers using `perm[i][0]` should switch to `perm[i]` or use `take_offsets([i])` to keep a one-row batch; out-of-bounds indexing now raises `IndexError`, and out-of-window identity `take_offsets` now raises `InvalidInput` (Python `ValueError`).
## Summary
`Permutation.__getitem__` documented a single row but returned `take_offsets([index])` after the current transform. The default transform is `batch.to_pylist()`, so `perm[0]` was a one-element list, which breaks per-index consumers like `torch.utils.data.DataLoader`.
An integer index now returns one row. List-producing transforms unwrap that element. Batch-shaped results stay as produced, so `with_format("arrow")[0]` is still a one-row `RecordBatch`. `__getitems__` and multi-row `take_offsets` still return the transformed batch. Negative indexes count from the end, and an out-of-range `__getitem__` raises `IndexError`.
### Identity permutation window
Identity `take_offsets` ignored `with_skip` and `with_take` and sent offsets straight to the base table. `len()` and `iter()` already honored that window, so a 10-row identity permutation with `with_skip(3).with_take(4)` iterated ids 3–6 while `perm[0]`, `take_offsets([0])`, and a DataLoader returned id 0. The identity reader now applies the same window. An offset outside it is an `InvalidInput` error (Python `ValueError`), matching a permutation-table reader whose offset is missing from the window map. On an identity permutation with no skip or take, an offset past the table length is now that error instead of an empty batch.
Related: #2996 (closed, but `perm[0]` still returned a list on current main)
Supersedes #3117, which is stale and only unwrapped the list in Python without the window fix.
## Test plan
- [x] `cargo fmt --all -- --check`
- [x] `cargo clippy --features remote -p lancedb --all-targets -- -D warnings`
- [x] `cargo test --features remote -p lancedb --lib dataloader` (52 passed, including new window tests)
- [x] `pytest python/tests/test_permutation.py python/tests/test_torch.py` (permutation + torch: 130 passed)
- [x] `ruff format --check` and `ruff check` in `python/`
Written with Cursor (Grok).
Co-authored-by: Maxwell Calkin <101308415+MaxwellCalkin@users.noreply.github.com>
`LanceNamespaceDatabase::rename_table` wrapped every namespace error in
a generic `Error::Runtime`, so renaming a missing table did not return
`TableNotFound`, unlike `drop_table`.
- Map errors through `map_namespace_lance_error`, so a missing source
table returns `Error::TableNotFound`.
- When the destination name is taken, report `TableAlreadyExists` with
the destination name, not the source name.
- Other errors no longer carry the "Failed to rename table:" prefix.
Tests: `test_namespace_rename_missing_table_returns_not_found` fails on
main with `Runtime { "Failed to rename table: Namespace error: Table not
found ..." }` and passes with this change.
`test_namespace_rename_to_existing_table_returns_already_exists` covers
the destination-name case.
## Summary
Fixes multiple panics and a `NaN` validation bypass in the dataloader
permutation split and shuffle configuration validation
(`rust/lancedb/src/dataloader/permutation/split.rs` and
`rust/lancedb/src/dataloader/permutation/shuffle.rs`), returning
`Error::InvalidInput` cleanly instead of crashing.
## Root Cause
Invalid configurations passed through Rust, Python, or Node.js bindings
could bypass validation or panic during validation/execution:
1. **`SplitSizes::Fixed(0)` divide-by-zero panic**:
`SplitSizes::validate()` evaluated `(num_rows / num_splits) == 0`
without first checking `*num_splits == 0`, panicking with integer
division by zero inside `validate()`.
2. **Empty `SplitSizes::Percentages` / `SplitSizes::Counts`
out-of-bounds panic**: Both passed `validate()` with `Ok(())` and later
panicked with index out of bounds (`split_sizes[split_id]`) in
`Splitter::sequential_split_id()`.
3. **`SplitSizes::Percentages` `NaN` bypass**: Because IEEE 754
comparisons with `NaN` return `false`,
`SplitSizes::Percentages(vec![f64::NAN])` bypassed `< 0.0 || > 1.0`, `<
1.0`, and `sum > 1.0` checks in `validate()`.
4. **Unchecked `u64` summation overflow**: `SplitSizes::Counts` and
`SplitStrategy::Hash` summed weights/counts with `.sum::<u64>()` / `+`,
panicking on overflow in debug builds or wrapping in release builds.
5. **`Shuffler::shuffle()` divide-by-zero panics**: The `clump_size ==
0` check lived only inside `do_shuffle()`, so inputs routed through
`in_memory_shuffle()` (when `num_rows < max_rows_per_file`, the default
path for datasets under 1M/10M rows) panicked in `shuffle_batch()` at
`.div_ceil(0)`. Similarly, `max_rows_per_file == 0` panicked in
`do_shuffle()` at `num_rows.div_ceil(0)`.
## Changes
- `rust/lancedb/src/dataloader/permutation/split.rs`:
- Reject `*num_splits == 0`, empty `Percentages`/`Counts`,
non-finite/`NaN` percentages via `!(0.0..=1.0).contains(percentage)`,
and overflowing `Counts` sums in `SplitSizes::validate()`.
- Reject `clump_size == Some(0)` in `SplitStrategy::Random` and
overflowing weight sums in `SplitStrategy::Hash` inside
`SplitStrategy::validate()`.
- `rust/lancedb/src/dataloader/permutation/shuffle.rs`:
- Validate `max_rows_per_file == 0` and `clump_size == Some(0)` upfront
at the entry of `Shuffler::shuffle()` so both in-memory and external
shuffle paths return `Error::InvalidInput` cleanly before creating
temporary directories or dividing.
- Add unit tests in `split.rs` and `shuffle.rs` covering all invalid
configurations end-to-end.
## Verification
- Confirmed all 5 new tests fail on `main` prior to the fix (including
division-by-zero panics at `split.rs:670`, `shuffle.rs:92`, and
`shuffle.rs:131`).
- Verified the full `dataloader::permutation::` unit test suite passes
after the fix:
- `cargo test --profile ci --locked -p lancedb --lib
dataloader::permutation::` (`54 passed; 0 failed`)
- `cargo fmt --all -- --check`
- `cargo clippy --profile ci --locked -p lancedb --lib --tests`
## Summary
Fixes stale-state overwrite and cache-wipe races in `BackgroundCache`
(`rust/lancedb/src/utils/background_cache.rs`) by advancing
`cache.generation` on every state transition out of or into a fetch
epoch.
## Root Cause
`BackgroundCache` tracks a monotonic `generation` counter so delayed
background tasks cannot clobber newer cache states, but previously
`generation` was only incremented in `invalidate()`:
1. **`seed()` did not advance `generation`**: If a caller invoked
`seed(value)` while an earlier fetch was still in flight, the in-flight
task still matched `cache.generation == generation` when it completed.
On `Ok(stale)`, it silently overwrote the seeded value with stale data;
on `Err(_)`, `State::Current` fell into `_ => None` and cleared the
seeded cache to `State::Empty`.
2. **`determine_action()`'s `future.peek()` transition and
`start_fetch()` did not advance `generation`**: When a caller consumed a
completed fetch via `future.peek()` before the fetch's spawned task
acquired the mutex (and potentially started a subsequent fetch), the
earlier fetch's delayed spawned task still observed the same
`generation`. On `Ok`, it could overwrite a newer in-flight fetch with
stale data; on `Err`, it could clear a newer `State::Refreshing` entry
and break single-flight coalescing.
## Changes
- Advance `cache.generation` via `wrapping_add(1)` in `seed()`,
`invalidate()`, `start_fetch()`, and the `future.peek()` transition in
`determine_action()`.
- Update the `generation` and `seed()` comments to document the
state-transition invariant.
- Add 4 deterministic async unit tests covering:
- `test_seed_during_inflight_fetch_prevents_stale_overwrite`
- `test_seed_during_inflight_fetch_error_preserves_seeded_value`
-
`test_peek_transition_prevents_delayed_task_from_clobbering_next_fetch`
-
`test_peek_transition_prevents_delayed_error_task_from_wiping_next_fetch`
## Verification
- Confirmed all 4 new unit tests fail on `main` prior to the fix (`4
failed`, reproducing stale overwrite, seeded cache wipe, in-flight fetch
clobbering, and broken coalescing).
- Verified all 19 tests pass after the fix:
- `cargo test --profile ci --locked -p lancedb --lib
utils::background_cache` (`19 passed; 0 failed`)
- `cargo fmt --all -- --check`
- `cargo clippy --profile ci --locked -p lancedb --lib --tests`
Embedded tag checkout replaced the handle's only branch identity. After
reading a tag on another branch, `checkout_latest()` followed that
branch and subsequent writes or restores could commit there.
Keep the handle's original branch and Lance `BranchIdentifier`
separately from its visible snapshot. A branch name alone cannot
distinguish the original branch from a replacement after deletion and
reuse. Cross-branch tags remain readable, and Python pickle and snapshot
copies preserve both identities. `checkout_latest()` reattaches to the
original branch, so later appends stay there. `current_branch()`
continues to report the visible snapshot's branch.
Validate the retained identity before `checkout_latest()` changes the
handle or `restore(tag)` commits; a reused branch name is rejected
without changing either branch tip. Independent and query snapshot
copies retain this identity too. Reject an ambiguous cross-branch
restore before committing. To restore on the tag's branch, first open a
handle there with `branches.checkout(...)` or Rust's
`checkout_branch(...)`. Update Rust, Python sync/async, TypeScript,
generated API documentation, and the tag-based versioning guide for this
behavior.
Python pickle state also carries the original `BranchIdentifier` through
reopening. A foreign snapshot stays readable if the originating branch
is replaced while serialized, but latest checkout and restore reject the
replacement. Latest and same-branch pinned handles validate the saved
identity before reopening returns. Older pickle states without the
identifier keep their existing reopen behavior; they cannot validate an
identity that was never saved.
Validation:
- All 12 new branch-name reuse regression cases failed before the
identity fix and pass afterward. They cover latest checkout and restore,
direct handles and snapshot copies, all three consistency modes, and
unchanged versions and contents on both branch tips. Query snapshot
identity retention is also covered.
- All 8 new Python pickle regression cases failed before the
serialization fix and pass afterward. They replace the branch while the
handle is serialized, cover latest checkout and restore across three
consistency modes, verify unchanged tips, and reject replacement data
when reopening latest or same-branch pinned handles.
- 494 Rust table tests and 23 dataset consistency tests passed with
`--features remote --profile ci`; Clippy for the core and Python
bindings, Rust formatting, and `git diff --check` passed.
- 62 targeted Python tag, branch, pickle, and restore tests passed in
the uv-managed environment after rebuilding the extension. An additional
compatibility check verified that older pickle states without the
identifier still reopen and return to the original branch.
- Earlier SDK validation: 9 targeted Node tests passed, including the
cross-branch regression. Node native build, TypeScript compilation,
lint/format checks, and API documentation generation passed. TypeScript
sources are unchanged in this Python pickle follow-up.
- Python package Ruff lint/format checks passed; repository-wide Ruff
reported 59 pre-existing findings in untouched `docs/web-tests/` files.
Vale 3.24.0 found no prose issues on the changed guide lines.
Fixes#4842
<!-- lance-gatekeeper-fix:v1 agent=c1c6448a3f02ec6db445df5e3d8dd77f
generation=1 -->
<!-- gatefixer-walkthrough:v1
head=078eceadbedc15cf179d9d4dcce249c83e7010f9 -->
## Change walkthrough
```mermaid
flowchart LR
A["Save original identity"] --> B["Reopen visible snapshot"]
B --> C{"Foreign snapshot?"}
C -->|No| D["Validate before return"]
C -->|Yes| E["Retain saved identity"]
E --> F["Validate latest or restore"]
```
**Read:** [Serialize and
reopen](https://github.com/lancedb/lancedb/blob/078eceadbedc15cf179d9d4dcce249c83e7010f9/python/python/lancedb/table.py#L4541-L4594)
→ [Reinstate identity
safely](https://github.com/lancedb/lancedb/blob/078eceadbedc15cf179d9d4dcce249c83e7010f9/rust/lancedb/src/table/dataset.rs#L278-L307)
→ [Serialized-handle
regressions](https://github.com/lancedb/lancedb/blob/078eceadbedc15cf179d9d4dcce249c83e7010f9/python/python/tests/test_table.py#L1300-L1360).
<sub>Snapshot:
[078ecea](https://github.com/lancedb/lancedb/commit/078eceadbedc15cf179d9d4dcce249c83e7010f9)</sub>
<!-- gatefixer-walkthrough:end -->
---------
Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
`AsyncTable.delete` does not drop indexes. On current main the reported
failure does not reproduce: delete forwards to Lance `dataset.delete`,
and index retention comes from Lance (the retention change in
lance-format/lance#4033, which closed lance-format/lance#3940), not from
recreating indexes after the delete. Nothing in this repo's CI currently
asserts it, so these tests lock that behavior in at the LanceDB level:
- Vector (IVF_FLAT), BTree, and full-text indexes survive deleting a
subset of rows, `delete("true")`, and a later insert. After the partial
delete, `list_indices` and `index_stats` still report indexed rows, and
scalar, full-text, and vector search return the live rows and omit
deleted ones.
- The reported empty-table sequence: `connect_async` to a directory,
create an empty table from a schema, `create_index(column="txt",
config=BTree())` before any rows, add 10 rows, then `delete(where="txt =
'1'")`. `list_indices()` still has one BTree on `txt`, the table has 9
rows, and the same holds after `open_table`.
This is an alternative to the approach in #2471, which saved and
recreated every index inside `delete`. That was declined by a maintainer
because it leaves a window with no indexes, and it is unnecessary now
that Lance keeps them.
Tests only: `rust/lancedb/src/table/delete.rs` and
`python/python/tests/test_table.py`. Both are deterministic (single IVF
partition, exact vectors, distinct FTS tokens) and run in well under a
second.
Refs #2434
## Test plan
- [x] `cargo test --features remote -p lancedb --lib
table::delete::tests::delete_keeps_vector_scalar_and_fts_indices` (5
runs)
- [x] `cargo clippy --features remote -p lancedb --tests -- -D
warnings`, `cargo fmt --all -- --check`
- [x] `pytest` on the two new Python tests (5 runs)
- [x] `ruff format --check .` and `ruff check .` in `python/`
Written with Cursor (Grok).
Co-authored-by: Preston Zhao <195942578+canyang25@users.noreply.github.com>
An older Function catalog can reject the query generated by
`get_function` at `FORMAT`, or by `list_functions` at `LIMIT`. When the
operation receives its exact trailing-input diagnostic at submission,
append guidance on matching the Python SDK to the Enterprise build. Keep
the original SQL error, request ID, gRPC status and any build metadata
supplied by the server.
Compared 24 loopback Flight responses through the public synchronous and
asynchronous Python APIs against the published b38 wheel. Eight lookups
and listings gained the pairing guidance. The other 16 responses
preserved their error types and diagnostics, including authorization,
missing resources and unrelated parser failures. The candidate passed
122 Python tests and four Rust tests. Current catalog reads and opaque
continuation tokens also worked after build discovery returned 404.
Enterprise SDKs use an inclusive 32 MiB default for eligible Blob V2
direct reads. The paired field comparison with the 10 MiB SDK default
measured higher direct-read latency at 10 and 16 MiB. At 32 MiB, the
interval for the latency difference spanned zero. [SDK version used in
the field comparison](https://github.com/lancedb/lancedb/pull/5247)
The earlier mixed-load test measured lower Plan Executor cache pressure
with direct reads enabled at the 10 MiB cutoff. That result covers the
tested size mix. With the 32 MiB cutoff, reads from 10 MiB up to (but
excluding) 32 MiB go through the proxy, so the impact on executor
traffic and cache pressure depends on the workload's size distribution.
The existing internal override still takes precedence. Direct reads keep
the 16 MiB part size. The Node binding test verifies proxy routing one
byte below the default and two contiguous object-store ranges with a
matching SHA-256 at exactly 32 MiB.
## Behavior
Presigned Blob V2 reads retry an idempotent ranged GET once after a
recognized disconnect or timeout before the complete response headers
arrive. This includes an abrupt TLS EOF while receiving the headers. A
retry preserves the physical Range and the still-valid URL. Expiry
triggers resolution on the pinned snapshot. Once the complete headers
arrive, the existing status and body paths handle the response.
Enterprise connections default to a 300-second pool idle timeout and
presigned object-store connections default to 30 seconds. The existing
override applies to both pools.
Loopback TCP tests exercise FIN and RST on a reused connection, both
with zero response bytes and after a partial header. They verify the
send count with retries enabled and disabled, the exact replayed Range
and the payload digest. A truncated body after complete headers returns
an error after one send.
Direct reads over 16 MiB stream bounded physical ranges into their
corresponding slices of the final buffer. The per-read fan-out uses
Lance's `LANCE_IO_THREADS`, capped by the connection's existing
`LANCE_CLIENT_BLOB_REQUEST_CONCURRENCY` limit (8 by default). Each
request retains its permit through body consumption. The 10 MiB routing
threshold continues to apply to the full logical read.
The connection can reuse unexpired presigned locations for verified rows
under the same table, column, snapshot and request credentials. Range
offsets and sizes come from the resolver. The existing batch request
covers the requested rows of a shared Packed or Managed sidecar.
Reopening a verified row uses its prior resolution, and the first open
of each unseen SQL descriptor still authorizes just that row. The public
API and REST response format are unchanged.
Local `merge_insert` skipped the mutability check, allowing a
version-pinned handle to commit onto its branch's latest version. Add
`ensure_mutable()` at the start of `NativeTable::merge_insert` so it
returns the same `InvalidInput` error as other writes before processing
the merge. This shared Rust path serves both Python and TypeScript local
tables.
Extend the existing branch-version and time-travel tests to cover pinned
opens and checkouts on main and named branches. Assert that rejection
preserves pinned data and the latest version, and that
`checkout_latest()` restores merge writes.
Validation:
- Both regression tests failed before the fix, reproducing successful
commits from pinned handles.
- Table tests: 405 passed (`cargo test --quiet --locked --profile ci
--features remote -p lancedb --lib table::tests::`).
- Merge tests: 20 passed (`cargo test --quiet --locked --profile ci
--features remote -p lancedb --lib table::merge::tests::`).
- `cargo clippy --quiet --locked --profile ci --features remote -p
lancedb --tests --examples` passed.
- `cargo fmt --all` and `git diff --check` passed.
Fixes#4844
<!-- lance-gatekeeper-fix:v1 agent=00c301b73fc482a11a5ccf15dea15981
generation=1 -->
<!-- gatefixer-walkthrough:v1
head=aa58a4d28a7596753bb44e3655d2839e07484398 -->
## Change walkthrough
```mermaid
flowchart LR
A["Native merge_insert"] --> B{"ensure_mutable"}
B -->|Pinned version| C["Return InvalidInput"]
B -->|Latest handle| D["Process merge"]
D --> E["Write data"]
```
**Read:** [Entry
guard](https://github.com/lancedb/lancedb/blob/aa58a4d28a7596753bb44e3655d2839e07484398/rust/lancedb/src/table.rs#L3972-L3986)
→ [Branch
pins](https://github.com/lancedb/lancedb/blob/aa58a4d28a7596753bb44e3655d2839e07484398/rust/lancedb/src/table.rs#L5141-L5158)
→ [Main pins and
reattachment](https://github.com/lancedb/lancedb/blob/aa58a4d28a7596753bb44e3655d2839e07484398/rust/lancedb/src/table.rs#L5488-L5518).
<sub>Snapshot:
[aa58a4d](https://github.com/lancedb/lancedb/commit/aa58a4d28a7596753bb44e3655d2839e07484398)</sub>
<!-- gatefixer-walkthrough:end -->
Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
Remote tag checkout discarded the tag's branch and pinned its version on
the handle's own branch without checking that the version existed. This
could read a different snapshot or leave the handle pinned to a
nonexistent version.
Resolve the complete tag reference and reject cross-branch tags with an
error naming both branches. For a tag on the handle's branch, reuse
numeric checkout to validate the version before committing the selector
and freshness state. This also protects Python's
`open_table(version=tag)`, which delegates to tag checkout. To read a
tag on another branch, obtain that branch's handle first with
`checkout_branch` in Rust or `table.branches.checkout(...)` in Python.
The Python checkout docstrings and tag-based versioning guide document
this requirement.
Add 17 regression cases covering cross-branch tags in both directions,
main-branch aliases, same-branch reads, and failed validation on
writable and pinned handles. Twelve cases failed against the original
implementation. Update the existing freshness and schema-cache tests for
the validation request.
Validation:
- `cargo test --locked --profile ci --features remote -p lancedb --lib
remote:: -- --quiet` — 921 tests passed using mocked remote endpoints.
- `cargo fmt --all` — passed.
- `cargo clippy --locked --profile ci --features remote -p lancedb
--tests --examples` — passed.
- Python documentation: Ruff lint and formatting checks passed for the
Python tree, using Ruff 0.15.20 from `python/uv.lock`. Python syntax
checks passed; executable ASTs are unchanged. Repository-wide `ruff
check .` reports 59 pre-existing errors in six unchanged
`docs/web-tests` files; unrelated formatter changes were excluded.
Fixes#4843
<!-- lance-gatekeeper-fix:v1 agent=2253a7bdebba53465089b95bce66cb12
generation=1 -->
<!-- gatefixer-walkthrough:v1
head=35f8db881e36b83b9aab478cb5db72e485c9eca7 -->
## Change walkthrough
```mermaid
flowchart TD
resolve["Resolve tag reference"] --> branch{"Same branch?"}
branch -->|No| reject["Return branch error"]
branch -->|Yes| validate["Describe tag version"]
validate -->|Error| error["Return version error"]
validate -->|Success| pin["Pin validated snapshot"]
```
The selector and freshness state commit together under the version lock.
**Read:** [branch
guard](https://github.com/lancedb/lancedb/blob/35f8db881e36b83b9aab478cb5db72e485c9eca7/rust/lancedb/src/remote/table.rs#L4075-L4092)
→ [validation and
commit](https://github.com/lancedb/lancedb/blob/35f8db881e36b83b9aab478cb5db72e485c9eca7/rust/lancedb/src/remote/table.rs#L2865-L2893)
→ [tag and branch
guidance](https://github.com/lancedb/lancedb/blob/35f8db881e36b83b9aab478cb5db72e485c9eca7/docs/web/management/table.mdx#L1745-L1755).
<sub>Snapshot:
[35f8db8](https://github.com/lancedb/lancedb/commit/35f8db881e36b83b9aab478cb5db72e485c9eca7)</sub>
<!-- gatefixer-walkthrough:end -->
---------
Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
Python callers inspecting a pinned Function version lose the explicit
primary package index URL even when the server includes it. Preserve
`runtime.environment.build.index_url` through `get_function` and
canonical JSON.
The requested build view contains only the explicit primary URL. Extra
indexes, other sources, and service defaults can still apply when that
view is absent. Compare the server's `runtime_digest` with the authored
runtime's digest for identity. The inspection view can omit inputs to
that digest.
Typed registration rejects nonempty build settings before issuing a
request. The existing decorator options and `refresh_lock` use the same
registration path.
Loopback Flight tests exercised sync and async pinned reads with a
primary index plus an extra index, and with only an extra index. They
also verified that typed submission rejects unsupported settings before
sending a request and still submits ordinary decorator definitions with
`refresh_lock`. A separate local replay verified pinned readback against
a published version with a credential-free primary index. The focused
suites passed 547 Python and 129 Rust tests, with three Rust tests
marked ignored.
Opening a table by URI and then checking out a retained version requires
the latest manifest to be readable. A caller that persisted a version
can now open that snapshot directly with
`NativeTable::open_at_version(uri, name, version, params)`. The caller’s
`ReadParams` apply during the open, and the returned table is pinned
with the usual read-only checkout semantics.
The regression covers reopening a retained version after a later
manifest becomes unreadable.