Commit Graph
3695 Commits
Author SHA1 Message Date
Brendan Clement fe2d2b33fc docs: restore setup in standalone Python examples (#4970)
Eight Python examples on the consistency, insert and merge-insert pages
are presented as complete programs, but the published snippets started
after the imports, temporary directory and connection, so they failed
with NameError when run on their own.

The snippet start markers had been moved below the setup in the test
files. This moves them back above it and regenerates the snippets.
2026-11-23 10:08:43 -08:00
Aiman MalibandClaude Opus 5.5 0f648bbad4 fix: allow BTree indexes on LargeUtf8 columns (#5089)
## What changed

`supported_btree_data_type` in `rust/lancedb/src/utils/mod.rs` now
accepts `LargeUtf8` next to `Utf8`. This is the only code change, one
line.

Python and TypeScript have no BTree type check of their own and call
into this function, so the fix covers all three SDKs. `Index::Auto` also
picks BTree for `LargeUtf8` columns now, locally and in the remote
client.

## Why

Fixes #5088

Lance builds BTree indexes on `LargeUtf8`, but this check in lancedb
rejected them with `A BTree index cannot be created on the field ...
which has data type LargeUtf8`. pandas 3 stores text columns as
`large_string`, so `create_index(col, config=BTree())` and
`create_scalar_index(col)` fail on tables created from a plain
DataFrame. #2297 removed a similar extra check for `FixedSizeBinary`.

`Binary`, `LargeBinary` and `Utf8View` may also be supported by Lance
but are left out of this PR.

## How it was tested

Run in a `rust:1.97.0-bookworm` container with `--profile ci --locked
--features remote`, on `main` at e29ec0e0. The branch is now rebased on
a6d7d02f, which only changes version numbers in
`Cargo.toml`/`Cargo.lock`; the commits are unchanged.

- New test
`table::create_index::tests::test_create_btree_index_on_large_utf8`
creates a BTree index (explicit and `Index::Auto`) on two `LargeUtf8`
columns, checks the index type, and checks that `=`, `>` and `IS NULL`
filters use `ScalarIndexQuery` and return the right row counts.
- On `main` without the fix, the new test fails with `A BTree index
cannot be created on the field ... which has data type LargeUtf8`. The
existing `test_create_zonemap_index_on_wider_scalar_types` and
`test_create_scalar_index` pass.
- With the fix: the new test passes in 5 consecutive runs, and
`create_index::`, `utils::` and `remote::table::` tests pass (559
passed).
- With the one-line fix reverted, the new test fails again and the
zonemap control passes.
- `cargo fmt --all -- --check` and `cargo clippy --features remote -p
lancedb --tests --examples -- -D warnings`: clean.
- Python and TypeScript code is unchanged, so `ruff` and `pnpm` were not
run.

Written with help from Claude Code.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 08:55:46 -08:00
Lucia CerchieandLucia Cerchie e9319c86bf fix: resolve agent plugin marketplace source (UAX-250) (#5170)
Looks like we have an issue with the plugin config pointing to a
non-existent dir.

Part of UAX-250. Related to UAX-245.

Clicktest, can ask Chat for example to create a fresh disposable config.

<img width="584" height="452" alt="Screenshot 2026-11-23 at 9 38 25 AM"
src="https://github.com/user-attachments/assets/d359f9e2-bd3f-4cb8-993a-7db3b2b20342"
/>

Clicktesting: Use a disposable Claude configuration. Add this checkout
as a marketplace, then install `lancedb@lancedb`. Confirm that
installation fetches `lancedb/lancedb-agent-plugins` and exposes its
skill.

*original prompt:*

"Work on Linear issue UAX-250:\
\
Suggested branch name:
luciacerchie/uax-250-add-enterprise-functions-guidance-to\
\
\<issue identifier="UAX-250">\
\<title>Add Enterprise Functions guidance to the lancedb agent
skill\</title>\
\<description>\
The public \`lancedb\` agent skill (\`lancedb/lancedb-agent-plugins\`,
v0.1.0) has no guidance on LanceDB Enterprise Functions. It also routes
"UDF / backfill" tasks to the Geneva/Ray path, which Functions is meant
to replace. Agents using the skill steer users away from our newest
product.\
\
\## Problem\
\
\* Nothing on \`@function\`, \`create_function\`, computed columns,
\`refresh_column_async\`, secrets, GPU classes, chunkers, or function
failure handling.\
\* The skill description does not trigger on Functions tasks.\
\* Function refresh jobs are not covered. \`remote_jobs.md\` only
describes \`geneva_jobs\`.\
\* \`lancedb/lancedb\` \`.claude-plugin/marketplace.json\` points to
\`./plugins/lancedb\`, which does not exist on main. Only
\`lancedb-agent-plugins\` installs.\
\
\## Proposed fix\
\
A patch is ready (new \`references/functions.md\`, \`SKILL.md\` routing
and description, \`remote_jobs.md\` note). Open a PR against
\`lancedb-agent-plugins\` and fix the marketplace path in
\`lancedb/lancedb\`.\
\
\## Acceptance\
\
\* A Functions prompt (register a function, bind a column, refresh,
retry failed rows) loads \`functions.md\` before Geneva.\
\* Add Functions prompts to the agent eval suite (see \<issue
id="08c7081c-2add-4ae6-b165-c9df1e23f1a5" label="UAX-245"
href="https\://linear.app/lancedb/issue/UAX-245/automated-docs-loop-to-update-skills"
/> for the docs-to-skills loop).\
\* Re-check the reference against each Enterprise release, since
Functions is early access.\
\
\## Related product gaps (for triage, not part of this issue)\
\
Many-to-many transforms (dedup, clustering), multi-GPU per worker,
refresh triggered on writes, per-row function version provenance,
SQL/Python option parity, TypeScript and Rust authoring.\
\
\>>> Agent notes\
\
Source: Enterprise 1.14.0 docs (function-authoring, function-operations,
function-failures, function-secrets, management/function,
create-function, refresh-column, auto-refresh, incremental-refresh,
chunking, sql/ddl/function). Needs the 0.42 preview client; stable 0.41
lacks these APIs. Local clone has the staged patch; no push access to
\`lancedb-agent-plugins\` from the session.\
\
\>>>\
\</description>\
\<team name="UX/AX Engineering"/>\
\<label>LanceDB Functions › UI/UX\</label>\
\<project name="Functions: Next">Functions roadmap and follow-up work
deferred from M3. Includes training integrations, application toolkits
and Ray interoperability requests; these are outside the M3 bug-bash
scope.\</project>\
\<issue-relations>\<related>\<issue-ref identifier="UAX-245"
title="Automated docs loop to update
skills"/>\</related>\</issue-relations>\
\</issue>"

Co-authored-by: Lucia Cerchie <cerchie@Lucias-MacBook-Pro.local>
2026-11-23 09:41:38 -07:00
Lance Release de81c35ba0 Bump version: 0.42.0-beta.25 → 0.42.0-beta.26 v0.42.0-beta.26 2026-11-23 06:14:22 +00:00
wangshun a0e65400a9 fix(java): keep Maven coordinates in sync with release tags (#5151)
Fixes #4937

## Summary

The `v0.42.0-beta.21` release commit retained `0.42.0-beta.20` in both
Java POMs, so its Maven build produced coordinates for the previous
beta. The release bump used a Maven version hook whose final shell
commands could return success after Maven failed, allowing the tag to be
created with stale coordinates. [Issue
#4937](https://github.com/lancedb/lancedb/issues/4937)

Declare both Maven version fields in the shared version-bump
configuration and align the checked-in POMs with the current release
version. Preview and stable release bumps now apply the same version to
the parent POM and the core module's parent reference before tagging.
Package names, dependencies, and publication destinations are preserved.

## Verification

Tests: `/bin/sh -c 'PATH=/tmp/osscout-release-venv/bin:$PATH bash
ci/tests/test_bump_version.sh'`.
Result: PATH=/tmp/osscout-release-venv/bin:$PATH bash
ci/tests/test_bump_version.sh — base exit 1 with the tag/POM mismatch,
patched exit 0 with both preview and stable cases passing.
Result: python -m unittest discover -s ci/tests -v — base, 35 passed.
Result: /tmp/osscout-release-venv/bin/python -m unittest discover -s
ci/tests -v — patched, 35 passed.
Result: bash ci/tests/test_cli_installer.sh — passed.
Result: cd java && ./mvnw --batch-mode test -pl lancedb-core — base, 37
passed on JDK 25.
Result: cd java && JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64 ./mvnw
--batch-mode -Dspotless.skip=true clean test -pl lancedb-core — patched,
37 passed. Surefire XML reports are in
java/lancedb-core/target/surefire-reports/.
Result: osscout_base_work=$(mktemp -d) && git archive HEAD java | tar
-xf - -C "$osscout_base_work" && cd "$osscout_base_work/java" &&
JAVA_HOME=/tmp/osscout-jdk8 ./mvnw --batch-mode -DskipTests
-Dspotless.skip=true clean deploy -pl lancedb-core -am -P deploy-to-fury
-DaltDeploymentRepository=fury::file:///tmp/osscout-fury-base — base
build succeeded and emitted stale 0.42.0-beta.20 artifacts for the
0.42.0-beta.21 release sources.
Result: cd java && JAVA_HOME=/tmp/osscout-jdk8 ./mvnw --batch-mode
-DskipTests -Dspotless.skip=true clean deploy -pl lancedb-core -am -P
deploy-to-fury
-DaltDeploymentRepository=fury::file:///tmp/osscout-fury-deploy —
patched build succeeded and emitted both 0.42.0-beta.21 POMs and the
main, sources and Javadoc JARs.
Regression coverage: `ci/tests/test_bump_version.sh`.
<!-- oss-scout-job:job-d5fa2e08-6a6f-46ca-821c-d3a65d054055 -->

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
2026-11-23 14:12:57 +08:00
Lance Release b5ec7d6af4 Bump version: 0.42.0-beta.24 → 0.42.0-beta.25 v0.42.0-beta.25 2026-11-23 02:50:01 +00:00
LanceDB Robot e3a55690e8 chore: update lance dependency to v15.0.0-beta.28 (#5163)
Updates the Rust workspace and Java dependencies to [Lance
v15.0.0-beta.28](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.28).
Pins the Python test extra to pylance 15.0.0b28 and refreshes its
lockfile.
2026-11-23 10:47:17 +08:00
Xuanwo 7c7765c91a fix(rust): validate batch vector column before planning (#5162)
Batch vector queries resolved an explicit vector column with an
infallible schema lookup before the existing vector-column validation
ran. A column that could not be resolved would abort planning instead of
returning the SDK's normal validation error.

Use the resolved column with `get_vector_type` so the batch path reports
the same typed error as ordinary vector queries, while keeping explicit
and inferred columns, multivector and binary routing, namespace
pushdown, and query-plan selection unchanged.

Adds a focused synthetic-schema validation test for the error path.
2026-11-23 08:56:49 +08:00
Lance Release f38d42e9db Bump version: 0.42.0-beta.23 → 0.42.0-beta.24 v0.42.0-beta.24 2026-11-22 21:22:21 +00:00
Xuanwo 59615eafac fix: reject blob request concurrency above semaphore limit (#5160)
## Summary

A `blob_request_concurrency` value above tokio's
`Semaphore::MAX_PERMITS` reached `Semaphore::new` and panicked, aborting
the process instead of reporting a configuration error. The value can
come from explicit client configuration or
`LANCE_CLIENT_BLOB_REQUEST_CONCURRENCY`, with a default of 8.

Resolve the value with the existing precedence, preserve the existing
zero and parse errors, and return `Error::InvalidInput` for values above
`Semaphore::MAX_PERMITS`. The supported range is documented on
`ClientConfig::blob_request_concurrency`.

## Tests

Added a focused resolver test covering the maximum accepted value and
one above it. The test passes an explicit value and does not mutate
environment variables.
2026-11-23 05:20:25 +08:00
Lance Release b654cd42ae Bump version: 0.42.0-beta.22 → 0.42.0-beta.23 v0.42.0-beta.23 2026-11-22 18:55:29 +00:00
LanceDB Robot b37de4edfe chore: update lance dependency to v15.0.0-beta.27 (#5159)
Update the Rust workspace Lance crates and Java `lance-core` to
`15.0.0-beta.27` and pin the Python test extra to `pylance==15.0.0b27`.
The Python lockfile includes the published wheels for the new version.

[Lance v15.0.0-beta.27
release](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.27)
2026-11-23 02:53:53 +08:00
Lance Release 21f074cb02 Bump version: 0.42.0-beta.21 → 0.42.0-beta.22 v0.42.0-beta.22 2026-11-22 14:27:15 +00:00
LanceDB RobotandXuanwo a09cd6fb8c chore: update lance dependency to v15.0.0-beta.26 (#5157)
Update the Rust, Java, and Python dependencies to [Lance
v15.0.0-beta.26](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.26).
Align the transitive Jieba macro version with Lance’s lockfile and fix
the Clippy diagnostics exposed by workspace validation.

Co-authored-by: Xuanwo <github@xuanwo.io>
2026-11-22 22:25:33 +08:00
Xuanwo b63cec40b4 fix(deps): update url to 2.5.9 for RUSTSEC-2026-0592 (#5158)
Updates the lockfile from `url` 2.5.8 to 2.5.9, the first release
patched for RUSTSEC-2026-0592, and from `form_urlencoded` 1.2.2 to
1.2.3, which `url` 2.5.9 requires (`^1.2.3`).

`main` also locks `url` 2.5.8. The advisory is the cargo-deny failure
currently blocking #5157, whose Lance beta.26 bump leaves the same
lockfile entry in place.

No dependency requirement or advisory ignore changes: `url = "2"`
already permits 2.5.9. `url` 2.5.9 declares MSRV 1.63 and
`form_urlencoded` 1.2.3 declares 1.51, both below the workspace's
1.95.0.

Validation:
- `cargo metadata --locked`
- `cargo tree -i url@2.5.9 --locked`
- `git diff --check`
2026-11-22 20:33:57 +08:00
Yang Cen d9b49e8889 feat: report capacity waits in function refresh job status (#5154)
An Enterprise Function refresh can spend time waiting for execution
workers. Applications polling `job.status()` currently see `running`
during that wait. Return `waiting_for_capacity` when the server reports
that phase for an active Function refresh. The next status request
reports `running` when execution resumes. Applications can use
`job.wait()` to wait through both states until completion.

Rust, Python and Node read the phase from the existing job description
response.

## Validation

Two HTTP regression tests exercise the public job handle. They cover the
wait, work resuming, completion after another wait, a stale phase at
completion, queued and paused refreshes, other job types, and servers
that omit the phase. The Rust CI remote job runs these tests.
2026-11-22 16:00:50 +08:00
Yang Cen 08ddcdb7d7 feat: resume a failed Function refresh from its table (#5153)
LanceDB Enterprise users can resume a failed Function refresh from its
table with `table.resume_refresh(job_id)`. The synchronous and
asynchronous Python APIs return a typed job handle. Waiting on that
handle uses the same table freshness tracking as a newly submitted
refresh.

The request carries the current table identifier and branch to the
server. The server decides whether the original attempt can be resumed
and supplies the reason when it cannot. The Python refresh methods also
accept a positive `max_job_attempts` option for automatic recovery.
These features require server support for Function refresh recovery.

The PR adds remote request, branch, error propagation, and typed result
tests. Python and Rust validation runs in PR CI.
2026-11-22 15:40:22 +08:00
Jack Ye 2b1b2a29dd feat!: layer GPU settings and total execution limits (#5146)
BREAKING CHANGE: Resource inputs use the same names at Function
registration, column/MV creation, and refresh. Use total_cpu_millis,
total_memory_bytes, and total_gpu_count for execution-wide worker
budgets, plus gpu_class and positive gpu_count for each worker. Replace
budget dictionary inputs and unprefixed aggregate limits with these
fields. Move existing refresh gpu_count caps to total_gpu_count;
gpu_count now selects devices per worker.

Each setting resolves independently: refresh > column/MV creation >
Function annotation > deployment. Creation settings also apply to
initial MV population and automatic refresh. MVs sum total budgets
across distinct pinned Function versions; per-worker GPU counts use the
largest Function default unless overridden. An unset GPU class resolves
to gpu_class="any" after inheritance; an explicit "any" overrides a
registered concrete class. Use gpu_class="default" to pin the default
pool explicitly.

```python
@function(
    gpu=True, gpu_class="h100", gpu_count=2,
    total_cpu_millis=8000,
    total_memory_bytes=16 * 1024**3,
    total_gpu_count=4,
)
def embed(text: str) -> list[float]: ...

version = db.create_function(embed)
table.add_columns(
    {"embedding": version(text=col("text"))},
    gpu_class="any", gpu_count=1, total_gpu_count=8,
)
table.refresh_column_async(
    "embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8,
)

mv = db.create_materialized_view(
    "embeddings", query="SELECT embed(text) AS embedding FROM documents",
    gpu_class="any", gpu_count=2, total_gpu_count=8,
)
mv.refresh(gpu_count=4, total_gpu_count=8)
```

```mermaid
flowchart TD
    R["Refresh settings"] --> E["Effective settings, resolved per field"]
    D["Column or MV creation settings"] --> E
    F["Function settings"] --> E
    C["Deployment defaults"] --> E
    E --> W["GPU class and device count per worker"]
    E --> T["Total CPU, memory and GPU ceilings"]
```

Pinned Function images retain their identity. Registration GPU counts
are defaults; execution overrides determine worker allocation. Admission
rejects GPU counts below an image's minimum requirement or above the
total budget. Python, Rust, SQL/REST and supported TypeScript operations
use the same resource model.

No local builds or tests, as requested; regression coverage runs in CI.
2026-11-21 15:04:34 -08:00
Jack Ye e3e55844bc fix: add SQL query timeout and cancellation controls
Add per-query SQL deadlines, read timeouts, and drop cancellation controls for Rust and Python.
2026-11-21 14:35:04 -08:00
Bruno Ramirez 7970d3075c docs: install the public CLI from the hosted script (#5139)
Installing the CLI from the guide previously required a repository
checkout or a manual download. The installer is available directly from
the downloads site. This updates the guide and quickstart for the
v0.42.0 stable release.
2026-11-21 13:52:49 -08:00
Xuanwo 564f8f93d4 test(python): cover embedded plans over enterprise bases (#5150)
## Summary

Clarify in the persistence guide and `persist` docstring that only the
plan destination must be Embedded. The base table can be Embedded or
Enterprise; an Enterprise base is pinned through the plan's recorded
base branch/version.

Add a focused loopback regression that persists a plan from a mock
remote base into an Embedded database, reopens the plan by destination
with `db.open_table`, advances the mock base's latest version to v2, and
verifies a fresh remote handle observes v2 while `Permutation` still
reads the plan's recorded main/v1 coordinates. Sequential iteration and
duplicate/unsorted offsets follow the stored plan order, and the mock
records nonempty v1 scan/gather requests.

## Verification

- Focused test plus affected remote mock tests: 3 passed.
- `ruff format --check` and `ruff check` passed.
- `git diff --check` passed.

This is a docs/test-only follow-up. It does not add Enterprise-resident
plan persistence or change plan ordering.
2026-11-21 17:09:53 +08:00
Lance Release b35cce60d6 Bump version: 0.42.0-beta.20 → 0.42.0-beta.21 v0.42.0-beta.21 2026-11-21 08:53:41 +00:00
Jack Ye 0511aed6e9 feat: profile Enterprise Function workers from official clients 2026-11-21 00:51:08 -08:00
Jack Ye 49dedd4329 fix: expose Function metadata in SDK job listings (#5096)
Expose affected columns, pinned Function name/version, completion time,
duration and failure summaries on `JobInfo` in the Rust, Python and
TypeScript SDKs. Values come from the listing response, so callers can
inspect recent computed column refreshes without opening every job.
Older servers keep optional values absent; measured zero durations stay
zero.

```python
latest = next((info for info in db.list_jobs(table="events", job_type="function_refresh") if "embedding" in info.columns), None)
if latest is not None:
    print(latest.function_name, latest.function_version, latest.duration_millis)
    if latest.failure is not None:
        print(latest.failure.message)
```

Duration is creation-to-completion wall time, including queueing and
pauses. Adds listing response coverage across SDKs and documents the
metadata contract, including SQL `SHOW JOBS EXTENDED` for the expanded
listing. Plain `SHOW JOBS` preserves its original columns. Local builds
and tests were skipped as requested.

The dependency advisory check also fails on current main because
`libsais-rs 0.2.0` is yanked ([main
job](https://github.com/lancedb/lancedb/actions/runs/44470513618/job/135378545456));
this PR does not change dependencies.

This changes the public shape of Rust and TypeScript `JobInfo`: callers
constructing summaries must supply the added fields (including
TypeScript `columns`). TypeScript table filtering remains a separate
concern; the guide now shows its client-side selection and namespace
limitation alongside Python and Rust server-side filters.

Refs ENT-3903.
2026-11-21 00:18:29 -08:00
Xuanwo 6a7a2c4ec0 feat(nodejs): add table delta streams (#5149)
Adds the Embedded `Table.delta` API to the Node.js bindings, matching
the Rust/Python contract from #5135. `Table.delta(fromVersion,
toVersion?)` accepts a positive safe-integer number, a positive lossless
u64 `bigint`, or a same-branch tag string. `TableDelta` exposes
`beginVersion`/`endVersion` as `bigint`, streaming `insertedRows()`,
`updatedRows()`, `upsertedRows()`, `deletedRowIds()`, and
`listTransactions()` with `readVersion` as `bigint`.

Readers reuse the existing native Arrow IPC iterator adapter. They are
lazy, single-use, serialize pulls, capture/cache the schema before
polling, and release the native stream on completion, break, or error.
Row readers retain the Rust contract: equal endpoints return empty
streams with schemas, invalid/reversed/missing endpoints and
cross-branch tags are rejected, and Restore or incomplete transaction
history fail closed with full-rescan and range-end checkpoint guidance.
Enterprise tables remain unsupported through the native Rust default.

The abstract `Table` keeps a concrete unsupported `delta` default for
custom subclasses; `LocalTable` overrides it. TypeDoc API docs and
focused Node tests cover pinned targets, typed bigint values,
transaction listing, lazy rejected readers, schema/decode failures,
aliasing, and early drop.

Refs OSS-2860
2026-11-21 15:43:16 +08:00
Jack Ye b44807e4db fix!: preserve job attempt lineage, retries, and lifecycle states
BREAKING CHANGE: JobDescription, JobEventsRequest, FunctionErrorsRequest, and FunctionErrors gain optional Rust metadata/cursor fields. Existing struct literals must initialize them; use None when unavailable.

Preserve typed attempt state, pinned retry lineage, result decoders and freshness fences, and retained diagnostic paging across SDKs. Keep Python job data access method-only.
2026-11-20 20:35:59 -08:00
Jack Ye bfb55c72e9 feat(python)!: make job data access method-only (#5095)
Make all Python `Job` and `AsyncJob` data access method-only. Cached
property accessors are private and underscore-prefixed; public reads use
`id()`, `state()`, `job_type()`, `creation_ms()`, `spec()`, `result()`
and `failure()`. `checkout_latest()` refreshes the complete cached
registry record in place and returns `None`.

```python
job.checkout_latest()
print(job.state(), job.result(), job.failure())
print(job.id(), job.job_type(), job.creation_ms(), job.spec())
```

Cached read methods are synchronous on both handle types. Async handles
use `await job.checkout_latest()` for the live refresh; event history
remains a separate request through `events()`. Update Python SDK
callers, tests and guides to use method calls, including
progress/timeout handling and bounded repr. Cover method-only visibility
and holistic snapshot freshness through both sync and async clients.

BREAKING CHANGE: Python job data access now requires method calls, such
as `job.state()` instead of `job.state`. No property compatibility
aliases remain.

Fixes
https://linear.app/lancedb/issue/ENT-3902/sdk-make-cached-versus-live-job-accessors-unambiguous
2026-11-20 17:37:12 -08:00
Brendan Clement 8b814731c3 docs: use function instead of deprecated udf in examples (#5027)
`lancedb.udf` is a deprecated alias of `lancedb.function` and emits a
`DeprecationWarning`. This switches the quickstart and the curation
examples to `function`, so readers who copy them no longer see the
warning. The quickstart snippet is regenerated from its test.
2026-11-20 16:11:29 -08:00
Xuanwo 61cabf1ccb feat(nodejs): add tag-based branch creation and default tag versions (#5145)
Node.js did not provide parity with the Python tag fixes in #5136.
`tags.create()` required an explicit version, and `branches.create()`
could not fork from a tag without resolving a numeric version that loses
the tag's branch identity.

This adds Node.js parity:

- `tags.create(tag, version?)` defaults an omitted version to the
version visible to the table handle, including checked-out and
time-travel handles. Explicit versions are unchanged.
- `branches.create(name, { fromTag })` forks through `Ref::Tag`,
preserving the tag's branch and version. Existing `create(name,
fromRef?, fromVersion?)` calls are unchanged. Mixing `fromTag` with
another source is rejected before `main` normalization.
- A missing Embedded branch keeps its original error and now includes
the actual `branches.create(..., { fromTag: ... })` call as guidance.
Enterprise 404s keep their original error without guessing from the
message.
- Enterprise uses the existing tag resolution and branch-create wire
contract; no wire changes.

The released web guide remains on the published package examples. The
new API is documented in the TypeScript API reference and source, with
Node regression coverage.
2026-11-21 06:53:10 +08:00
Xuanwo 8dc03bd288 feat: add table.delta for version-to-version row changes (#5135)
Adds native `Table::delta(from_version, to_version=None)` and Python
sync/async `table.delta(...)` for version-to-version row changes.
`TableDelta` exposes streaming `inserted_rows()`, `updated_rows()`,
`upserted_rows()`, `deleted_row_ids()`, and `list_transactions()`.

Endpoints are resolved once on independent dataset handles.
`to_version=None` uses the table handle's visible snapshot, and the
handle's checkout is not changed. Only versions `>= 1` and tags on the
current branch are accepted; cross-branch tags, reversed ranges, version
0, and missing endpoints are rejected. Equal valid endpoints return
empty readers with the same schemas.

Row-level readers require stable row ids at both endpoints and report
the `storage_options={"new_table_enable_stable_row_ids": "true"}`
creation guidance when they are absent. `list_transactions()` does not
require stable row ids.

Row-level readers also fail closed when the range contains a `Restore`,
or when transaction history cannot prove the range is restore-free,
because restored rows can retain older row-version metadata that the
delta readers omit. The error directs consumers to a full rescan and
reinitializing the checkpoint at the range end version.
`list_transactions()` remains available for readable history. The
Versioning guide includes Python and Rust checkpoint-delta examples with
stable-row-ID setup and this Embedded limitation.

Embedded `branches.diff()` remains a separate API.

Refs OSS-2860
2026-11-21 06:41:38 +08:00
Bruno Ramirez baea02eebd feat: add cleanup jobs and previews across SDKs (#5107)
LanceDB SDK users connected to Enterprise had no explicit API to submit
durable cleanup or preview its work; Python's existing cleanup helper
remained a warning-only no-op. This PR adds the SDK support for
[ENT-2687](https://linear.app/lancedb/issue/ENT-2687) through public SQL
and Job APIs. It requires a compatible Enterprise release supporting
`VACUUM`, JSON preview and result format version 1. Existing
cleanup/optimize helpers retain their behavior; the new APIs reject
Embedded and historical-version handles.

This was accomplished with the following changes:

- Add `cleanup_async()` / `cleanupAsync()` and `explain_cleanup()` /
`explainCleanup()` in Python sync/async, TypeScript and Rust.
- Preserve the handle's namespace/branch and resolve retention as
invocation → table/branch TTL → deployment default. Omission inherits,
zero is explicit, and malformed options fail rather than being
discarded.
- Require one nonempty durable SQL receipt, preserving diagnostics
without REST fallback, query-ID substitution or automatic resubmission
after ambiguous acceptance.
- Add versioned `CleanupPlan` estimates and `CleanupResult`
measurements. Preview creates no cleanup job or reservation; results
preserve known zero, unknown retry/recovery totals and nonfatal failed
deletes, excluding auxiliary sweeps.
- Retain typed results on reopening and reuse shared
status/progress/events/wait/cancel APIs. Timeout leaves work running;
cancellation cannot undo deletion or prove storage I/O stopped.
- Document Ownership/parent Usage and required coordination at every
retention value: disable/drain automatic cleanup and prevent competing
cleanup, tag creation/update, branch creation and restore across all
clients until completion. The server does not enforce exclusion;
concurrent restore can leave the current table unreadable.
- Update Python's legacy no-op warning and the maintenance, Python, Rust
and generated TypeScript references.

| Interface | Submit with seven-day retention |
| --- | --- |
| SQL | `VACUUM events WITH (min_age_seconds = 604800);` |
| CLI | `lancedb admin table cleanup --table events --min-age-seconds
604800 --wait` |
| Python | `job = table.cleanup_async(min_age_seconds=604800)` (use
`await` with AsyncTable) |
| TypeScript | `const job = await table.cleanupAsync({ minAgeSeconds:
604800 });` |
| Rust | `let job =
table.cleanup_async(CleanupOptions::new().min_age_seconds(604800)).await?;`
|

### Testing

Added submission/preview, validation, typed-result and reopening tests,
and updated the legacy no-op warning assertion. Focused Python
cleanup/Job and compaction/prewarm regressions passed, alongside **34
TypeScript** and **46 Rust** tests. **31 end-to-end scenarios** passed
against a real Enterprise server, covering CLI/SQL/REST/SDK submission,
retention precedence, restart/reopening, timeouts, cancellation and
branch/namespace isolation.

Local native SDK validation used a separate `libsais-rs 0.2.0` lockfile
because the registry could not resolve `0.2.4`; this PR retains main's
dependency pins and lockfile.
2026-11-20 14:34:07 -08:00
Xuanwo 8fd1c716d9 feat(python): persist permutation plans and reopen pinned snapshots (#5137)
## Summary

Add `permutation_builder(base).persist(db, table_name, *,
namespace_path=None, mode="create").execute()` for embedded local and
object-store destinations. The native create request carries the
namespace and create/overwrite mode, with no drop-before-create. The
returned table keeps the destination connection context so it can be
pickled and reopened directly, including namespaced and manifest-enabled
connections.

Persisted plans pickle by reference to their own branch and version, so
a later overwrite or cross-branch checkout does not change what an
existing pickle reads. In-memory plans, old serialized state, and
shallow copies keep their existing behavior. `Permutation.base_version`
and `base_branch` expose the recorded base snapshot from loaded
metadata. Enterprise destinations remain rejected in v1 because
reproducible remote plan ordering is follow-up work.

## Verification

- `test_permutation.py`: 93 passed.
- `test_torch.py`: 23 passed in a compatible torch 2.15 / NumPy 2.2 /
PyArrow 26 environment using the abi3 extension.
- S3 direct-result persistence/pickle test passed against a disposable
loopback Moto server using the existing fixture's fake keys and explicit
storage options.
- Earlier targeted checks predate the live snapshot pin repair: Rust
builder tests 12 passed; Rust check/clippy and Node type-check passed.
- The live snapshot pin repair added private PyO3 glue and was verified
with a rebuilt extension: `test_permutation.py` 93 passed,
`test_torch.py` 23 passed, and one loopback S3 direct-result test
passed.
- `ruff format --check`, `ruff check`, `pyright`, `git diff --check`:
passed.
2026-11-21 06:27:27 +08:00
Xuanwo 8b8778938f perf(python): stream plain sync batches on demand (#5143)
## Problem

Synchronous local `table.search().to_batches()` creates one Python
future per batch through the background event loop. At the default
1024-row cap, a large scan pays that Python round trip thousands of
times even though the Rust stream can produce the next batch
immediately.

## Change

Use a pull-driven synchronous reader for native, non-namespace, ordinary
lazy plain scans. The query is executed once with the same
`QueryExecutionOptions` as the async path: `None` keeps the 1024-row
cap, `0` leaves sizing to the engine, and a positive value caps each
returned batch. Each `__next__` releases the GIL, waits for exactly one
batch from the same Rust stream through the reviewed
`block_on_interruptible`, and stores the stream back on success.

- No background producer and no Python `LOOP.run` per batch.
- A read error, interrupt, EOF, or the last owner drops the stream. A
normal early `break` can resume the same reader.
- The public `pa.RecordBatchReader` still comes from `from_batches`, so
the schema, Arrow capsule, and exception types stay unchanged. Existing
PyArrow `close()` behavior is unchanged; the known PyArrow close issue
is separately scoped.
- Routing is limited to native, non-namespace, lazy plain scans. Vector,
take, FTS/hybrid, remote, namespace, `to_arrow` direct eager routes, and
Blob `bytes`/`descriptions` keep their existing paths. Take ordering
from #5140 remains on the take path.
- Forward explicit `scan_in_order` through the pull launch; base-only
ordered `to_batches` results and the incompatible `order_by`/fragment
behavior are included in the scan-order suite.
- Adds a public RTE `to_batches` regression: the default LSM route sees
pending memtable writes, while `use_rte(False)` remains base-only.

## Validation

- `test_sync_pull_reader.py`, `test_merge_insert_lsm.py`, and
`test_sync_query_direct.py`: 53 passed.
- `test_query.py`, `test_blob.py`, and
`test_blob_query_without_pylance.py`: 539 passed, 1 skipped.
- `test_table.py`: 552 passed, 17 skipped.
- `test_remote_db.py -k "to_batches or take"`: 16 passed.
- `test_background_loop.py`: 4 passed.
- Rust `cargo test --manifest-path python/Cargo.toml --lib sync_stream`:
5 passed.
- `cargo check -j 1 --manifest-path python/Cargo.toml --lib --tests`
passed; no full Rust doctests were run.

A matched same-base release-with-debug streaming comparison is a
follow-up and is not claimed here.

Tracking: [OSS-2865](https://linear.app/lancedb/issue/OSS-2865)
2026-11-21 06:25:05 +08:00
Xuanwo 87262842e0 docs(function): document GPU row deadline guidance (#5144)
Enterprise GPU Functions on 1.13.0 through 1.14.1 and on 1.15.0 builds
before the shared 300-second default was restored reject a refresh
without an explicit positive `row_timeout_seconds`.

The GPU authoring example and the `@function`/`@udf` docstrings now
carry the requirement, the definition/request precedence, and sizing
guidance. The 600-second value is a working example from the reported
workload, not a recommendation.
2026-11-21 05:37:28 +08:00
Xuanwo c55b7c0390 feat!: add explicit scan order contract for local queries (#5138)
BREAKING CHANGE: `QueryRequest` now has a public `scan_in_order:
Option<bool>` field. Existing code that constructs `QueryRequest` with
an exhaustive struct literal must add `scan_in_order: None` to retain
the previous backend default, or use `..Default::default()` where
appropriate. Python defaults are unchanged: leaving `scan_in_order()`
uncalled keeps `None`.

## Problem

Plain Embedded LanceDB scans already use Lance's ordered scan on a fixed
snapshot, but the storage-order contract was undocumented and callers
had no way to require it. Explicit `order_by` sorts the whole result.
Ranked, Enterprise, RTE/LSM, legacy scalar-index and namespace-pushdown
paths cannot always preserve base manifest order.

## Behavior

- `scan_in_order(true)` requires manifest order without adding a sort:
fragments in manifest order, then rows in fragment order.
- `true` disables scalar-index filter planning. Legacy scalar-index
plans can materialize index rows in a different sequence, so filters are
evaluated over the manifest-ordered scan instead. Filter semantics are
unchanged, but the scan can read more data. Default filtered scans can
still use those plans and may not preserve manifest order.
- `scan_in_order(false)` permits the backend to scan unordered. It does
**not** guarantee a different order; an explicit nonempty `order_by`
still sorts.
- Leaving the option unset preserves the backend default. The documented
manifest-order default applies to an unfiltered base-only scan of a
pinned Embedded table version. RTE tables scan the LSM by default and
need `use_rte(false)` for the base-only guarantee. Enterprise and
namespace-pushed scans have no order guarantee.
- `true` conflicts with nonempty `order_by`, take queries,
vector/full-text/hybrid/reranked queries, RTE/LSM reads, and Enterprise
tables. These fail explicitly instead of silently dropping the
requirement. Take conflict validation happens at the shared
take-preparation boundary before offset or row-id selectors are
stripped.
- `with_fragments()` is rejected with `scan_in_order(true)` because
fragment objects cannot be validated against the pinned dataset version.
Use `fragment_ids()`, which resolves fragment ids from the manifest and
preserves manifest order. Both sync and async pandas scanner paths share
this rule.
- Namespace `QueryTable` pushdown executes `true` against Embedded
storage instead of dropping the order. The existing path preserves
projection, filtering, limits, version/branch selection, and RTE
routing; if Embedded storage cannot be read, the query fails.

Supported entry points are plain Rust `Table::query()`, Python sync
`table.search()` and async `table.query()`. The Python pandas scanner
fast path forwards the option and disables scalar-index planning for
explicit order. Existing takes and `with_fragments()` calls with `None`
or `false` are unchanged.

## Validation

- Rust: 6 `scan_in_order` tests, 32 take tests, 25 query-route tests.
- Python: `test_query.py` and `test_namespace.py` 352 passed, 1 skipped
against a matching extension.
- Scoped `pytest --doctest-modules python/lancedb/query.py -k
scan_in_order`: 2 passed. The Rust/Python examples create their own
tables and are executable.
- Regressions cover legacy 0.1 and stable BTREE tables with update and a
filter admitting every row, across pinned versions before and after
update; reversed `fragment_ids`; explicit `with_fragments()` rejection;
and fixed-version multi-fragment reads with deletions, one-row batches,
and limit/offset. No `SortExec` is added.
- `cargo clippy --features remote --tests --examples`; `cargo fmt
--check`; Ruff format/check; `git diff --check`.
- Local checks ran on this branch. CI on this PR evaluates the merge
with current `main`; no combined local binary validation is claimed
here.

Refs OSS-3109.
2026-11-21 05:20:16 +08:00
Xuanwo 0d2655edba test(python): isolate the background-loop fork scenario (#5142)
## Summary

Follow-up to #5111.

`test_forked_child_starts_background_loop_lazily` forked the shared
pytest process. On CI that process may already own native
Tokio/parking_lot state from earlier tests such as `test_authz.py`, so
the forked child can crash in a non-Python native thread during
`table_names()` for reasons unrelated to this scenario.

Run the entire fork scenario in a fresh `python -c` subprocess. The
parent still starts `LOOP` via `parent-before`, forks while holding
`LOOP._start_lock` (released in `finally`), and the child still verifies
that it sees no inherited loop, thread, or background threads before
using the real native sync API (`connect("memory://")` /
`table_names()`). The child must then gain exactly one live daemon
thread, while the parent's original thread stays alive and serves
`parent-after`.

This is test isolation, not a production fix or a root-cause claim. The
original assertions and cleanup are preserved, with a 40s outer timeout
for `join(20)`, `terminate()` + `join(5)`, `queue.get(5)`, and
diagnostics.

## CI evidence

The failure was observed on a docs-only main run (`b4459f35`), so it is
not caused by a product change in that run:

- [Minimum dependencies job
136441279987](https://github.com/lancedb/lancedb/actions/runs/44780367013/job/136441279987):
timed out at ~20s.
- [Linux Python 3.13 job
136441280394](https://github.com/lancedb/lancedb/actions/runs/44780367013/job/136441280394):
native SIGSEGV in a non-Python native thread during `table_names()`
after `connect`, following `test_authz.py` in the same stage.

## Validation

- `python/tests/test_background_loop.py`: 4 passed.
- Same pytest process, `test_authz.py` followed by
`test_background_loop.py`: 83 passed.
- `uv run make check`: cargo fmt, ruff format, cargo clippy, and ruff
check passed.

No production code changes.
2026-11-21 05:04:30 +08:00
Xuanwo 668fb1e256 feat(python): add tag-based branch creation and default tag versions (#5136)
Python `tags.create()` now defaults `version` to the handle's currently
visible version, including checked-out handles. Existing `from_ref` /
`from_version` branch selection and explicit tag versions keep their
current behavior.

`branches.create()` gains keyword-only `from_tag`, so a branch can fork
from a tag through the existing `Ref::Tag` path. This preserves the
tag's actual branch snapshot; resolving only its numeric version could
fork from `main` when both branches share a version number. `from_tag`
conflicts with `from_ref` / `from_version` are rejected before
`from_ref="main"` normalization.

When `from_ref` names a tag instead of a branch, the native
missing-branch failure keeps its classification and receives a static
`from_tag=` hint without another lookup. A missing version and an
ambiguous Enterprise 404 keep their original errors.

The Python sync and async APIs, PyO3 binding, stubs and docstrings are
updated together, with native Rust coverage for a tag on a branch that
shares main's numeric version. Node.js `fromTag` and optional `version`
will follow in a separate PR after this one.
2026-11-21 04:59:34 +08:00
Brendan Clement 74239973c7 docs: describe current Function refresh defaults (#5134)
Several Function pages still said a refresh defaults to `error_policy =
'fail'` and that `skip` writes null outputs. The server now defaults new
refreshes to skip with a 5% failed-row ceiling, and skip keeps a row's
existing output, leaving only never-filled rows empty. This updates
those pages to match.
2026-11-20 12:47:31 -08:00
Xuanwo 13fe33581e perf(python): add direct sync query execution (#5141)
## Summary

Route ordinary local `table.search(...).to_arrow()` queries through
private synchronous schema and eager-collection bindings instead of the
Python background event loop. Plain scans, vector searches (including
default vector-column inference), and native FTS in lazy Blob mode now
complete with zero `LOOP.run` submissions.

The synchronous path reuses the existing query lowering, core query
execution, eager collector, Arrow ownership, projection validation,
fragments, row ids, Blob finalization, reranking, and snapshot handling.
It uses the generation-scoped Tokio runtime and `OutstandingGuard`,
releases the GIL while waiting, checks CPython signals on the caller
thread at a bounded interval, and aborts and drops collected state when
a handler raises. Multi-threaded Tokio callback re-entry uses
`block_in_place`; current-thread contexts return a Python error.
Namespace, RemoteTable, Enterprise, streaming, take, and non-lazy Blob
routing are unchanged. No public API is added.

## Benchmark

Workload: 200,000 rows, 64 dimensions, BTREE on `id`, IVF_PQ on
`vector`; 50 warmups + 500 calls, p50/p99 of three alternating runs.
Build: `release-with-debug`. Baseline Python package from `03fc5404` ran
against the same candidate extension as the candidate, so this isolates
the Python event-loop route; a separately built matching baseline
extension is a follow-up validation target. The host had competing Rust
builds, so these numbers are preliminary, not isolated release
throughput.

| Workload | LOOP/schema per call before -> after | p50 before -> after
| p99 before -> after |
|---|---|---|---|
| plain point lookup `to_arrow()` | 2 / 1 -> 0 / 1 | 2.32 / 3.26 / 2.64
ms -> 1.64 / 1.89 / 1.80 ms | 3.87 / 3.92 / 3.69 ms -> 2.42 / 2.63 /
2.62 ms |
| indexed vector `to_arrow()` | 3 / 2 -> 0 / 2 | 5.20 / 5.13 / 3.79 ms
-> 4.65 / 4.22 / 4.31 ms | 7.18 / 7.52 / 6.45 ms -> 6.29 / 6.01 / 6.43
ms |

`to_batches()` remains on the existing streaming path. OSS-2868
1/2/4/8/16-thread scaling and fully matched build artifacts remain
separate follow-up.

## Validation

- `test_sync_query_direct.py`: plain/vector/native FTS with `LOOP.run`
patched to fail, default vector inference, empty schema, timeout,
single-worker progress-callback re-entry, and SIGINT/runtime reuse.
- `test_query.py` with direct tests: 253 passed, 1 skipped.
- `test_blob.py`: 266 passed, 1 skipped.
- `test_fts.py` + `test_rerankers.py`: 163 passed, 13 skipped.
- `test_table.py` + `test_namespace.py` + `test_sync_api_parity.py`: 649
passed, 17 skipped.
- Remote query/blob/schema subset: 206 passed.
- Runtime unit tests: 12 passed; `cargo check`, `cargo clippy`, `cargo
fmt --check`, and Python ruff passed.

The SIGINT case is marked slow and was run in focused validation; it is
not part of the default suite. Refs OSS-2867 (non-closing).
2026-11-21 04:41:11 +08:00
Xuanwo a3b6fecfd6 feat(python)!: preserve input order for take offsets (#5140)
## Summary

Add an opt-in `preserve_order` flag to sync and async `take_offsets`. It
exposes the existing Rust `TakeRestoreExec` ordering path and carries
the flag through `QueryRequest`, `PyQueryRequest`, and the Python
`Query` model.

## Behavior

- Default `preserve_order=False` keeps the existing incremental,
unspecified-order behavior.
- `preserve_order=True` returns found rows in input order, including
repeated offsets.
- Missing non-negative offsets keep filter semantics and are omitted;
negative offsets remain rejected by the existing `u64` contract.
- Rust take queries apply `limit`/`offset` after order and repetition
are restored. Python take builders and Query conversion do not expose
pagination.
- An explicit `order_by` conflicts with offset `preserve_order` and
raises clearly. `take_row_ids` keeps its existing implicit ordering and
explicit-sort behavior.
- `__getitems__` is unchanged: it keeps its Python re-alignment and
strict missing-offset (`ArrowIndexError`) behavior.

## Remote lookup

The remote lookup sends only the deduplicated `_rowoffset IN (...)`
filter and restores order/repetition client-side; there is no new wire
field or backend extension. Namespace take queries stay on local
execution, and RTE/LSM rejects the `_rowoffset` lookup loudly.

## Testing

- Old reviewed head reproduced the serialization regression:
`test_query_serialization_sync/async` failed because the Query model
exposed `False` for an unset field.
- Fixed by using `Optional[bool] = None` and mapping Rust `false` to
absent in `PyQueryRequest`; explicit `True` still survives the actual
round trip.
- `python/tests/test_query.py`: 253 passed, 1 skipped.
- Rust preserve-order tests: 3 passed; row-id/order-by tests: 27 passed.
- Remote ordered Blob bytes, remote permutation, and Blob mode focused
cases: 3 passed.
- `cargo fmt --check`, `ruff format/check`, `py_compile`, and `git diff
--check` passed.

## Migration

`lancedb::query::QueryRequest` is a public non-`#[non_exhaustive]`
struct. Downstream code that constructs it with an exhaustive struct
literal must add `preserve_order: false` or use `..Default::default()`.
The field is client-side metadata and is not sent over the remote
protocol.

Seekable Blob APIs, rollout, and ENT-4059 remain separate work.

Refs OSS-2881 (non-closing).
2026-11-21 04:35:13 +08:00
Xuanwo 1658c8d762 feat(python)!: support vector columns in permutation torch formats (#5131)
BREAKING CHANGE: `Permutation.with_format("torch_row")` now uses PyTorch
dtype promotion instead of NumPy promotion. Mixed numeric columns can
change dtype, for example int64 and float32 now produce float32 instead
of float64. Cast columns before formatting when the old dtype matters.
Nullable scalar integer and floating columns still produce NaN; nulls in
nested fixed-size-list or tensor columns, and in bfloat16 columns, are
rejected.

## Problem

`Permutation.with_format("torch")`, `"torch_col"`, and `"torch_row"`
fail when the selected columns include a vector (`FixedSizeList`)
column, which is the column training workloads need. The conversion also
has to preserve Arrow slice offsets, logical `FixedShapeTensor` axes,
and visible nested nulls instead of flattening over them.

## Behavior

- Add `with_format("torch_dict")`: a dict of per-column `(B, *S)`
tensors, usable directly with a `DataLoader` identity collate. Tensors
share Arrow storage where the layout allows.
- Extend `torch` per-row dicts to nested `FixedSizeList` and
`FixedShapeTensor`; PyTorch's default collate stacks them back into `(B,
*S)` tensors.
- Preserve `torch_col` as `(C, B, *S)`, including a zero-copy
`unsqueeze(0)` view for one column.
- Preserve `torch_row` as per-row `(C, *S)` tensors, including `(1,)`
for one scalar column, with `torch.promote_types` for mixed numeric
dtypes. Nullable scalar integer and floating columns keep their previous
NaN behavior; nested fixed-size-list and tensor nulls are rejected.
- `torch_col` and `torch_row` reject heterogeneous sample shapes with
the field names, shapes, and guidance to `torch_dict`.
- Support nested fixed-size lists, `FixedShapeTensor` logical axis
permutations, boolean/integer/floating leaves, empty batches, and
nonzero slice offsets. `torch_dict`, `torch`, and `torch_col` reject
visible nulls.
- NumPy still returns one ndarray. Its pandas conversion may copy, may
promote mixed numeric columns to a common numeric dtype (for example
int64 and float32 to float64), and produces an object array for nested
or incompatible columns.
- `lance.bfloat16` is accepted only for a `FixedSizeBinary(2)` leaf
carrying the `ARROW:extension:name` metadata; offsets/length and byte
order are handled before viewing as `torch.bfloat16`. Unmarked binary
columns are rejected.

This is Python-only and does not change persistence, pickling, or public
method signatures.

## Validation

- `pyarrow 26.0.1`, `torch 2.15.0+cu132`, Python 3.12: `test_torch.py`
23 passed; `test_permutation.py` 84 passed.
- Minimum `pyarrow 16.0.0`, `torch 2.0.1+cpu`, Python 3.11: the nullable
scalar, mixed-dtype, null-rejection, and NumPy tests passed (4 focused
tests). The new NumPy test skips without pandas via
`pytest.importorskip`.
- The pre-existing fork DataLoader tests are flaky only when the full
`test_torch.py` file runs on the minimum stack; each passes when run
alone. Their failure is on the default Python format path and does not
exercise the changed format conversions.
- `ruff format`, `ruff check`, and `git diff --check` pass.
2026-11-21 02:21:51 +08:00
Christopher Krah 7eb40118ac fix(python): write enum members as their values in table.update (#5061)
`table.update(values=...)` fails for a member of an int- or float-valued
Enum. `value_to_sql` dispatches it to the `int` or `float` handler, and
`str()` returns the member name, so the SQL reads `priority =
Priority.HIGH` as a field access. A plain Enum member raises
`NotImplementedError`. #3232 stores a `(int, Enum)` field as int64 and
#4357 writes Enum fields as their values on `add`, so only `update`
disagrees.

```python
class Priority(int, Enum):
    HIGH = 2

table = db.create_table("t", data=[{"id": 1, "priority": 1}])
table.update(values={"priority": Priority.HIGH})
# lancedb 0.41.0: ValueError: Invalid input, Execution error: Cannot access field at argument 1: type Int64 is not Struct, Map, or Null
```

The int and float handlers now convert with `int()` and `float()` first,
and an `Enum` handler writes `value.value`. Str-valued members already
worked, because `str.replace` returns a plain `str`. No issue is open
for this.

```
$ cd python && pytest python/tests/test_util.py -k enum_members -q   # 2ab103d7 plus this commit, lancedb 0.42.0b15 extension
1 passed, 139 deselected, 1 warning in 0.36s
# util.py reverted, test kept
E       AssertionError: assert 'Priority.HIGH' == '2'
1 failed, 139 deselected, 1 warning in 0.29s
$ ruff format --check . && ruff check .   # ruff 0.9.9, as CI pins
191 files already formatted
All checks passed!
$ pyright   # 1.1.414
3 errors, 0 warnings, 0 informations   # the same 3 in __init__.py at 2ab103d7
$ pytest python/tests -m "not slow and not s3_test" -q
1 failed, 4144 passed, 198 skipped, 73 deselected   # 2ab103d7: 1 failed, 4143 passed
# the failure in both is test_public_function_values_are_in_api_reference, which reads docs/ and my tree exported python/ only
# not run: remote and s3 tests
```

@Xuanwo, if you'd rather `update` reuse the #4357 converter than grow an
Enum branch in `value_to_sql`, I'll move it there.

Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
2026-11-20 09:53:49 -08:00
Brendan Clement cfa94f0077 docs: add the documentation style guide to this repository (#5132)
`CONTRIBUTING.md` and the Vale rules link to `lancedb/docs`, which is
private, so outside contributors get a 404. Fixes #5070.

This copies the style guide to `docs/STYLE.md` and points the links at
it. The text is the same apart from the intro, which now describes the
scope from this repository's side, and the internal-names bullet, which
no longer lists the names.

The other three links in `CONTRIBUTING.md` went to the docs repository's
README. The draft-section example is now inline. The combined preview
and saved-edition corrections need the private repositories, so the
guide says to ask a maintainer in the pull request instead.

Replaces #5091.
2026-11-20 09:47:14 -08:00
Will JonesandClaude Opus 5.5 b4459f35e6 docs: teach agents Embedded/Enterprise terms and deprecation rules (#5108)
## Summary

Coding agents keep writing "local/remote tables" in new docs,
docstrings, and error messages, partly because `AGENTS.md` itself still
describes the two backends that way. Recent PRs also removed released
APIs instead of deprecating them, and put migration notes in the user
guide. This updates `AGENTS.md` so implementing agents learn these
conventions up front:

- Use "Embedded" and "Enterprise" in user-facing text. `remote` stays as
the internal module, feature, and type name.
- Deprecate released public APIs rather than removing them, and don't
reuse a released name for a different meaning.
- Keep `docs/web` guides evergreen. Deprecations are marked in
docstrings, and breaking changes go in a `BREAKING CHANGE:` paragraph in
the PR body.

`REVIEW.md` gets the matching wording fix and a short checklist so
automated reviews catch the same things.

## Merge Risk

**Door:** two-way; agent guidance only.
**Blast Radius:** none

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:08:22 -08:00
Xuanwo 03fc5404ae perf(python): deduplicate sync query preparation (#5130)
## Summary

Sync query execution rebuilt schema-derived state several times inside
one call: for vector-column inference, blob projection validation,
row-id preparation, async handoff, and result finalization. A plain
point lookup paid five schema reads and five background-loop submissions
per `to_arrow()`.

This change prepares the schema and projected blob sources once per
execution and reuses them through scan setup, result finalization, and
the async handoff. Sync-prepared queries tell the async layer that blob
row ids are already resolved; nothing is cached between executions, so a
reused builder still observes schema changes. Plain scans and explicit
vector columns no longer read the schema just to infer a vector column,
and the dead vector conversion in `LanceVectorQueryBuilder.to_batches()`
is removed.

Non-lazy vector `to_arrow()` stays on its lazy materialization path, so
reranking and snapshot merging run once before the aggregate blob
conversion. Async behavior, namespace routing, fragments, timeouts, and
public APIs are unchanged. A direct synchronous Rust terminal remains
follow-up work.

## Benchmark

Workload: 200,000 rows, 64 dimensions, BTREE on `id`, IVF_PQ on
`vector`; 50 warmups + 500 calls per run; p50 of three runs. Baseline
and candidate Python packages ran against the same `release-no-lto`
extension built at `a2176f9b`; only package source differed. Local NVMe,
single host.

| Workload | Loop/schema per call before -> after | p50 before -> after
|
|---|---|---|
| plain point lookup `to_arrow()` | 5 / 5 -> 2 / 1 | 6.06 / 6.08 / 5.67
ms -> 3.26 / 3.26 / 3.33 ms |
| indexed vector `to_arrow()` | 5 / 5 -> 3 / 2 | 8.82 / 8.21 / 8.35 ms
-> 6.40 / 6.55 / 6.60 ms |
| plain point lookup `to_batches().read_all()` | 6 / 4 -> 4 / 1 | 6.88 /
7.25 / 6.94 ms -> 4.37 / 4.80 / 3.76 ms |

`release-no-lto` is a local comparison build, not a release-profile
number. The branch includes a merge of current main (`a2176f9b`, #5129);
the affected blob, reranker, FTS, query, and namespace checks were rerun
against the merged tree.

Refs OSS-2867 (non-closing).
2026-11-21 00:49:47 +08:00
Xuanwo a2176f9bcd fix(python): preserve blob query snapshots and row-id guidance (#5129)
## Summary

- Preserve the query snapshot carried by a remote query result when
`fetch_blobs` or `fetch_blob_files` receives that result table, instead
of reading row IDs from the table's current snapshot.
- Send the expected `x-lancedb-query-snapshot` on the descriptor take
used by `fetch_blob_files` and verify the response echo before decoding
any descriptor. NULL and empty descriptors cannot escape unverified.
- Point missing `_rowid` and missing row-id errors at
`take_offsets(offsets, with_row_id=True)` for callers that have row
positions, while keeping the existing missing/deleted row-id details.
- Keep `fetch_blobs` row-ID based. Positional access and seekable
video/DataLoader handle design remain separate work aligned with
ENT-4059; this PR does not add `offsets=` or change that contract.
- Document the behavior and keep empty row-id requests at zero I/O.

## Compatibility

Server 0.5.0 is the basic remote Blob API floor. Snapshot-bound
descriptor reads need the actual query identity echo from the serving
node (Sophon #10211, present in tag v1.13.0). If identity cannot be
verified, `fetch_blob_files` fails explicitly instead of accepting
descriptors. Metadata-free row-id input keeps the existing
current-snapshot behavior. This does not claim production rollout or
real server testing.

## Testing

- `python/tests/test_blob.py`: 249 passed, 1 skipped
- `python/tests/test_remote_db.py -k blob`: 133 passed
- Rust remote blob-file unit tests: 13 passed
- `cargo check --features remote --tests --examples`
- `cargo fmt --all --check`, `ruff format` and `ruff check`

Refs OSS-2881 (non-closing).
2026-11-20 23:47:26 +08:00
Xuanwo d46754cad4 feat: register blob bases during table creation (#5117)
## Summary

`create_table` / `create_empty_table` now accept registered storage
bases and the embedded opt-in for blob URIs outside them. A create with
data registers `initial_bases` in the same commit, so external Blob v2
references no longer need an empty create followed by `add`.

- Rust `CreateTableBuilder::initial_bases` /
`allow_external_blob_outside_bases`, with `BasePath` re-exported.
- PyO3 and Python sync/async create paths accept lightweight `BasePath`,
dicts, and duck-typed `lance.DatasetBasePath`; `id=None` lets Lance
assign an ID and explicit `0` or duplicate explicit IDs are rejected.
- `blob_uri_array` builds the standard four-field `lance.blob.v2` array
without pylance and keeps field metadata such as
`lancedb:logical_type=mp4`.
- Enterprise create rejects non-empty `initial_bases` and the true
opt-in before normalization, input iteration, or HTTP; empty/false
defaults remain an ordinary create.
- Native namespace create merges namespace and connection storage
options into the caller's store parameters instead of replacing them.
This is reconciled with #5114's refresh layering, so caller-scoped
options survive create, refresh, and reopen while namespace-vended
values keep their precedence.
- The outside-base opt-in applies to one write: setting it on create
does not carry over to a later `add()`.

## Validation

- `cargo fmt --all -- --check`, `cargo check --quiet --features remote
--tests --examples`, `cargo clippy --quiet --features remote --tests
--examples`.
- Rust: `blob_integration` 66 passed, `database::namespace` 23,
`connection::create_table` 16, `remote::db` 128.
- Python: `test_blob.py` 263 passed / 1 skipped, `test_blob_array.py` 4,
remote create 12, `test_db.py -k "pickle or create_table"` 15,
`test_namespace.py -k "pickle or refresh or create"` 29, `test_table.py
-k pickle` 8; ruff 0.9.9 and pyright from `python/`.
- `test_blob.py` also passes with pylance and pandas removed (177 passed
/ 87 skipped), matching the CI no-pylance suite. The lightweight and
dict create cases keep version, schema, reopen, and exact-range
assertions there; only the pylance-only manifest introspection moved
into the `DatasetBasePath` case.
- Rust and sync Python two-base probes assert that base 1's scoped
option fails its read while base 2 still returns exact bytes after
reopen. A separate async namespace test covers create and reopen with
exact ranges.
- `test_namespace_refresh_layers_caller_scoped_options` covers the
expired namespace seed: create-time `base_1.caller_scoped` survives
refresh, vended `timeout` is replaced (7s to 8s), fresh namespace values
appear, and reopen with the caller option returns exact blob range bytes
through the registered base.
- Updated `main` through #5127 (including #5114) is merged;
`rust/lancedb/src/database/namespace.rs` and `rust/lancedb/src/table.rs`
match `main`, and no #5114 code was stacked before it merged.

## Dependency note

The Lance dependency stays pinned at the `v15.0.0-beta.25` release on
`main`. With that pin, mixing an automatic base ID (`id=0`) and an
explicit non-zero ID may still collide; the approved upstream fix is
https://github.com/lance-format/lance/pull/11307. Use distinct explicit
non-zero IDs for multi-base creates, or automatic IDs for every base,
until a Lance release containing that fix is pinned. A failed mixed
create can leave the table name listed but unopenable; retrying with
distinct explicit IDs succeeds. Multi-base validation here uses explicit
IDs and bootstrap uses a single automatic ID, so the mixed-ID case is
not claimed as verified until a Lance release containing that fix is
pinned.
2026-11-20 22:17:47 +08:00
Xuanwo 85f966a9a9 fix: add dataset path hint and sync open_table location (#5128)
## Summary

- Expose `location=` on sync `LanceDBConnection.open_table()`, matching
the existing async entry point while leaving remote and namespace APIs
unchanged.
- When a `ListingDatabase` connection URI ends in `.lance`, append a
parent-directory and table-stem hint to the derived-URI `TableNotFound`
error. The error classification and source chain are preserved, and no
extra storage probes are made.

Context: OSS-2858 remains canceled. This is only the narrow embedded DX
follow-up; it does not add a top-level `lancedb.open_table(uri)` API.

## Verification

- Rust targeted listing tests for the `.lance` hint and the
explicit-location path.
- Python sync `open_table` tests for `location=` and the `.lance` hint.
- Pickle round-trip of a sync `location=` table after #5114.
- `cargo check --features remote --tests --examples`, `cargo fmt
--check`, Ruff format/check.
2026-11-20 22:08:29 +08:00
Xuanwo 9799686986 perf(python): add native eager collection for to_arrow (#5127)
## Summary

`to_arrow()` currently collects results one Python future per batch:
both sync and async paths call `to_batches()`, which crosses the
Python/Rust bridge for every default 1024-row batch. Vector queries also
materialize the whole native stream even when no reranker is configured.

This adds a shared Rust eager collector. `execute_to_reader` collects
the batches in Rust, asks the core to skip the default 1024-row output
slicing, and exposes the result through the Arrow C Stream interface, so
Python builds the Table without a Python future per batch. Sync and
async `to_arrow`, including FTS, vector and hybrid eager paths, use it.
`AsyncVectorQuery.to_batches` no longer materializes results when there
is no reranker and now honors `max_batch_length`.

Schema, empty results, timeout, cancellation, and error behavior are
preserved. The existing fragment guard is enforced on the new fast path,
and namespace-pushdown routing keeps its existing Python/Rust split.

## Benchmark

Development-profile editable build, full scans on one revision, 1 warmup
+ 5 measured runs. Absolute values are not release-profile numbers;
compare before/after on the same build.

| Workload | Before | After |
|---|---|---|
| 5M rows x 3 columns, async | 3.054 s | 0.087 s (35.1x) |
| 5M rows x 3 columns, sync | 3.462 s | 0.090 s (38.3x) |
| 200k rows x 129 columns, async | 0.354 s | 0.082 s (4.3x) |
| 200k rows x 129 columns, sync | 0.387 s | 0.085 s (4.5x) |

The narrow scan returned 4,883 batches capped at 1,024 rows before and
611 batches up to 8,192 rows after.
2026-11-20 21:30:40 +08:00
Xuanwo dcded7fb70 feat(python): default StreamingDataLoader workers to forkserver (#5112)
## Problem

`StreamingDataLoader` left PyTorch's platform default in place for
worker processes, which is `fork` on Linux. Forked workers inherit the
parent process's native runtime and connections, which is the failure
mode behind the fork-isolation work.

## Behavior

When `num_workers > 0` and `multiprocessing_context` is omitted or
`None`, workers now use `forkserver` when the platform provides it,
otherwise `spawn`. Explicit start-method names and context objects are
unchanged. With `num_workers == 0`, no context is selected, preserving
PyTorch's single-process handling. Callbacks and worker state must be
picklable under the selected start method, following PyTorch's
DataLoader rules.

Existing `StreamingDataset` serialization is sufficient for the default
worker path. This does not change the explicit fork opt-in or the native
client reopen path in #3851.
2026-11-20 21:01:25 +08:00