Commit Graph
3777 Commits
Author SHA1 Message Date
Christopher Krah c0d46c31ba fix(python): map a Literal with None to a nullable field (#4927)
`pydantic_to_schema` raises on `Literal["a", "b", None]`, a field
pydantic accepts with `None`. [PEP
586](https://peps.python.org/pep-0586/#legal-parameters-for-literal-at-type-check-time)
reads it as `Union[Literal["a", "b"], None]`, the same type as
`Optional[Literal["a", "b"]]`, which #4678 maps to a nullable `utf8`.
The `None` is the optional part, not a second value type, so #4678's
rule that `Literal["a", 1]` raises does not cover it. The Literal branch
counted `NoneType` anyway and raised "All values of a Literal must have
the same type".

Before, on `1157a07`:

```
$ python probe.py
Optional[Literal]: pyarrow.Field<kind: string>
pydantic accepts None: kind=None
Literal[..., None]: TypeError: Converting Pydantic type to Arrow Type: unsupported type typing.Literal['a', 'b', None]. All values of a Literal must have the same type.
```

After, the last line prints `pyarrow.Field<kind: string>`, nullable. No
issue exists for this.

<details><summary>probe.py</summary>

```python
from typing import Literal, Optional
from lancedb.pydantic import LanceModel, pydantic_to_schema

class Opt(LanceModel):
    kind: Optional[Literal["a", "b"]] = None

class Lit(LanceModel):
    kind: Literal["a", "b", None] = None

print("Optional[Literal]:", pydantic_to_schema(Opt).field("kind"))
print("pydantic accepts None:", Lit(kind=None))
try:
    print("Literal[..., None]:", pydantic_to_schema(Lit).field("kind"))
except TypeError as e:
    print("Literal[..., None]: TypeError:", e)
```

</details>

The fix has two halves, and each test fails without one of them.
`_unwrap_optional_annotation` turns `Literal["a", None]` into
`Literal["a"]`, so the field and a list item become nullable. The
Literal branch skips `None` when it collects value types, so
`Optional[Literal["a", None]]` maps too. A mixed `Literal["a", 1, None]`
still raises, and so does a bare `Literal[None]`.

### Verification

```
# Python 3.12, lancedb 0.42.0b9 wheel from pypi.fury.io (the version at 1157a07), its _lancedb.abi3.so in the tree
$ PYTHONPATH=. python -m pytest -q -p no:cacheprovider tests/test_pydantic.py
this branch:                         87 passed
pydantic.py reverted, tests kept:    2 failed, 85 passed   (TypeError: ... must have the same type)
None kept in the value types only:   1 failed, 86 passed
unwrap change reverted only:         2 failed, 85 passed   (status not nullable; the write fails)
$ PYTHONPATH=. python -m pytest -q -p no:cacheprovider tests/test_pydantic.py tests/test_table.py tests/test_db.py
1157a07:      8 failed, 650 passed, 17 skipped
this branch:  8 failed, 652 passed, 17 skipped   # the same 8 in test_table.py (blob, merge, compact, namespace) on both
$ ruff format --check <both files> && ruff check <both files>      # ruff 0.9.9, as CI pins it
2 files already formatted
All checks passed!
# not run: the Rust build, the full suite; pyright's include list leaves out pydantic.py
```

@Xuanwo, you merged #4678. I left a bare `Literal[None]` raising, since
a column that can only hold null has no value type to store. Does that
match how you want it?

---------

Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
2026-11-30 19:16:26 +08:00
Tomwang.eth 855bec2a57 fix(node): make tags.list() values plain serializable objects (#4915)
Related: #4849 (same defect class on `branches.list()`, fixed in #4914).

**Problem**
`Tags.list()` returns napi class instances whose fields live on the
prototype, so `console.log`, spread and `JSON.stringify` show `{}` — the
documented example (`{ "v1": { version: 1, manifestSize: ... } }`)
doesn't match what users actually see. Property access
(`tags["v1"].version`) works, which is why the existing tests didn't
catch it.

**Change**
- `TagContents` stays a runtime napi class export: existing ESM named
imports of `TagContents` and `instanceof` checks keep working, and
existing TypeScript values remain assignable to it.
- `nodejs/lancedb/table.ts` post-processes `Tags.prototype.list()`
results, promoting `version` and `manifestSize` to own enumerable
properties on each returned instance by reusing the class getters and
setters. Values are now enumerable, spreadable and JSON-serializable
with no fields added, removed or renamed.
- TS-only: the Python SDK already returns proper dicts with both fields.

**Tests**
- New regression test in `nodejs/__test__/table.test.ts` covers the
named import and `instanceof` alongside own-enumerable keys, spread and
a JSON round-trip through `tags.list()`.
- The tag tests from #5145 are kept and pass against this change.
- Verified locally on Linux x86_64: `tsc -b`, Biome checks, and the
focused tags suite (4 passed), including `tags.create(name)` /
`tags.create(name, null)` behavior.
2026-11-30 19:14:23 +08:00
Jyotishman Dasandrishi02102017 163177f6a5 fix(python): report iterator schema mismatches in create_table (#4921)
When `create_table()` is given an iterator and a later item can't be
cast to the schema of the first one, the user gets an `AttributeError`
instead of the intended schema-mismatch error:

```python
def batches():
    yield [{"id": 1, "text": "a"}]
    yield [{"id": "two", "text": "b"}]

db.create_table("t", batches())
# RuntimeError: ... Unknown error: 'list' object has no attribute 'schema'
```

The same happens with pandas DataFrames, and with `table.add(...,
on_bad_vectors="drop" | "fill" | "null")`, which goes through the same
helper. A plain `table.add(batches())` already reports the mismatch
correctly.

The cause is in `_iterator_to_reader`: the error message reads `.schema`
from the raw item the iterator yielded rather than from the Arrow table
it was converted to. This PR uses the converted table's schema, as
`scannable._from_iterable` already does, and adds a regression test in
`test_db.py` that fails without the change.

With the fix, the error is:

```
Input iterator yielded a batch with schema that does not match the schema of other batches.
Expected:
id: int64
text: string
Got:
id: string
text: string
```

Tested with `pytest python/tests/test_db.py python/tests/test_table.py
-m "not slow and not s3_test"` (574 passed, 17 skipped) and ruff on the
changed files.

---------

Co-authored-by: rishi02102017 <rishi02102017@users.noreply.github.com>
2026-11-30 19:14:15 +08:00
Alex Castillo González f639e178a1 fix(python): skip empty or null texts in bedrock-text embeddings (#4919)
With `bedrock-text`, a single empty or null cell in the source column
makes `add()` fail while computing embeddings, before `on_bad_vectors`
gets a chance to run, so `on_bad_vectors="drop"`, `"null"` and `"fill"`
have no effect.

**Root cause:** `BedRockText.generate_embeddings` sends every text to
`invoke_model`, including empty strings and `None`. Bedrock rejects an
empty `inputText` (minimum length 1), and the error is re-raised as a
`ValueError`. The `openai`, `oci_genai` and `nvidia` functions already
return `None` for such entries, and `table.py` passes `None` vectors on
to `on_bad_vectors`.

**Fix:** skip `None` and empty strings in `generate_embeddings` and put
`None` in their slot (other values, such as `False`, are still sent, so
their input error reaches the caller); the other texts are embedded as
before and keep their positions. With the default
`on_bad_vectors="error"`, `add()` still raises, now with the bad-vector
error that points at `on_bad_vectors` instead of a boto3 error.

**Tests:** `test_embeddings_bedrock.py` uses a fake bedrock-runtime
client that rejects an empty `inputText`, and checks `["alpha", "" /
None, "be"]` returns `[[5.0], None, [2.0]]` with only two calls made.
Both cases fail on `main` and pass with the change. An `add()` through
the same fake client with `drop`, `null` and `fill` fails on `main` and
succeeds here (2, 4 and 4 of 4 rows). A `table.add()` with a `False`
source under `on_bad_vectors="drop"` checks that the non-string input
error still reaches the caller. None of this was run against live
Bedrock.

This change was prepared with the help of an AI assistant (Claude), and
the submitter is responsible for it.


---------
2026-11-30 19:14:08 +08:00
Alex Castillo González fc13fd6e98 fix(nodejs): batch OpenAI embedding requests to 2048 inputs (#4833)
`OpenAIEmbeddingFunction.computeSourceEmbeddings` in the Node SDK sent
every row in a single `embeddings.create` call. `makeArrowTable` passes
the whole source column at once, and the OpenAI embeddings endpoint
accepts at most 2048 inputs per request, so `table.add` (or
`createTable`) with more than 2048 rows and an `openai` embedding
function fails with a 400.

This splits the input into chunks of at most 2048 and concatenates the
results in order. Inputs of 2048 rows or fewer still make one request,
as before.

Test: `nodejs/__test__/embedding_openai.test.ts` mocks `openai`
(rejecting requests with more than 2048 inputs) and checks that 5000
rows produce 5000 embeddings, in order, over three calls (2048, 2048,
904). It fails without the change and passes with it.

This change was prepared with AI assistance (Claude Code).
2026-11-30 19:14:00 +08:00
Preston ZhaoandPreston Zhao 3e31cd4eab test: lock in that delete keeps table indices (#5168)
`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>
2026-11-30 19:12:12 +08:00
Deniz Erdogan 53ae53877d docs: fix dead links to the Lance catalog specs (#5208)
Six `See https://lance.org/format/namespace/{dir,rest}/catalog-spec/`
comments in `docs/web/management/namespace.mdx` point to pages that
return 404. The Lance docs moved the directory and REST catalog specs to
`/format/catalog/dir/` and `/format/catalog/rest/`, so the comments now
use those URLs.

Only comment text changed. I opened both new URLs and they return 200.
2026-11-30 19:10:10 +08:00
dayan02dev b0aa0de889 fix(python): accept nullable merge_insert input on tables with a primary key (#5297)
## Why
After `set_unenforced_primary_key`, `merge_insert` from a DataFrame, a
list of dicts or an inferred-schema Arrow table fails, while `add()` of
the same rows works:

```python
t = db.create_table("t", pa.table({"id": pa.array(["a"]), "n": [1]}, schema=pa.schema([pa.field("id", pa.string(), False), pa.field("n", pa.int64())])))
t.set_unenforced_primary_key("id")
t.merge_insert("id").when_matched_update_all().when_not_matched_insert_all().execute([{"id": "b", "n": 2}])
# RuntimeError: lance error: LanceError(Schema): Primary key column and all its ancestors must not be nullable: Field(id=0, name=id, type=string)
```

`_align_field` copies the table field's metadata onto the nullable
source field, so the source schema marks a nullable `id` as the primary
key and Lance rejects it. merge_insert takes the key from the dataset
schema and rejects null keys on write, so the source doesn't need the
marker.

## What changed
`AsyncTable._do_merge` (used by sync, async and remote tables) drops the
primary-key markers from source fields that are nullable or under a
nullable struct. `create_table` and `add` are unchanged.

## Tests
New tests in `test_table.py` and `test_remote_db.py` fail without the
fix.

#5081 has the same message but a different cause in Lance
(lance-format/lance#11212).
2026-11-30 19:08:13 +08:00
DogerW 06828e2842 fix(python): handle JSON schema callbacks on LanceModel fields (#5300)
Fixes #5299.

Pydantic accepts a callback in `Field(json_schema_extra=...)` for
customizing a field's JSON Schema. Creating an Embedded table from a
model with such a field raised `AttributeError` when LanceDB tried to
read embedding metadata with `.get()`.

Read LanceDB metadata from mapping-style extras and leave callbacks to
Pydantic. The regression test creates a table with the expected Arrow
string column, then verifies that the callback still removes the field's
default from its JSON Schema.

### Validation

- The new test failed with the reported exception on `9a79107` before
the fix.
- All 97 tests in `test_pydantic.py` and
`test_embedding_field_metadata.py` passed on Python 3.11.15 with
Pydantic 2.13.4, using the checkout's Python sources and the published
0.42.0b38 native extension.
- Verified create, insert and read-back on Python 3.12.7 with Pydantic
2.14.4. Ruff lint and formatting checks passed for the Python SDK.
2026-11-30 19:07:29 +08:00
Alex Castillo González 9564431b57 fix(python): support Cohere embed-v4.0 in CohereEmbeddingFunction (#4805)
`CohereEmbeddingFunction(name="embed-v4.0")` raised `ValueError: Model
embed-v4.0 not supported`.

**Cause.** `ndims()` uses a closed list of v2/v3 model names and raises
for everything else, so Cohere's current embedding model was rejected.

**Fix.** Add `embed-v4.0` to `ndims()`, returning its default output
dimension (1536).

**Test.** `test_cohere_embed_v4_is_supported` creates the function with
`name="embed-v4.0"` and checks `ndims() == 1536`. It fails before the
change with the `ValueError` and passes after; the existing Cohere
default-model test still passes.

This change was prepared with the help of an AI assistant (Claude Code),
and the author is responsible for the change.


---------
2026-11-30 19:06:26 +08:00
Raunak Kumar Pandey f1320b8ef9 fix(python): skip null text when reranking with Jina (#5296)
Fixes #5295.

Vector results can include a row with a valid vector and null text. The
Jina text reranker would send that null in `documents`, although the API
requires text documents. Filter the Arrow table before extracting
request documents so returned indices still select the correct rows and
retain their original scores. When every candidate lacks text, return a
typed empty result without contacting Jina.

Both regression cases failed on the upstream Python source and passed
with the change. They cover a null before two valid documents, reordered
response indices, preservation of row IDs, distance and schema, and an
all-null input with no request. The local test loaded the exact source
reranker modules on top of LanceDB 0.41.0 with PyArrow 26.0.1 and a
mocked HTTP client. Ruff lint, formatting and whitespace checks passed.
This test did not use a live Jina service. AI assistance was used to
investigate and draft the change.

Signed-off-by: Raunak <raunakpandey1007@gmail.com>
2026-11-30 18:16:11 +08:00
Stella 4feffc649a docs: add License section to README (#5291)
Adds License section.
2026-11-30 18:10:44 +08:00
Xuanwo 7a2182c95b docs(nodejs): clarify macOS prebuilt binaries are Apple silicon only (#5244)
The Node.js README lists Intel Macs among the platforms that receive a
native binary from npm. The macOS package is published for Apple silicon
(`arm64`) only. Intel Mac users can follow the [source-build
instructions](https://github.com/lancedb/lancedb/blob/main/nodejs/CONTRIBUTING.md#development).

Refs #3149 and #4765.
2026-11-30 18:04:49 +08:00
Muhammad Abdullah ButtandXuanwo 8a00ca58ea fix(nodejs): send Lance time units when altering timestamp or duration columns (#5196)
`alterColumns` serializes an Arrow `dataType` with `dataTypeToJson`. For
`Timestamp` and
`Duration` it wrote apache-arrow's numeric `TimeUnit` value into the
type string, so a cast to
`new TimestampMicrosecond()` was sent as `timestamp:2:-` and
`Duration(MICROSECOND)` as
`duration:2`. Lance only parses the units `s`, `ms`, `us` and `ns`, so
every such alteration
failed with `Invalid data type: {"type":"timestamp:2:-"}`.

This maps `TimeUnit` to Lance's unit strings for both types.

Tests:
- arrow.test.ts: checks `dataTypeToJson` output for all four units of
both types, with and
without a timezone. It fails on main (`timestamp:0:-`) and passes with
the fix.
- table.test.ts: "can cast to various types" now also alters
timestamp[ms] and duration[ms]
  columns to microseconds and checks the schema.

I couldn't build the native module locally, so the arrow.test.ts run
used the released 0.37.1 binary, and the table.test.ts steps were
checked as a standalone script against that package rather than under
jest.

I made this change with help from Claude Code, and I reviewed the diff
and the test results myself.


---------

Co-authored-by: Xuanwo <github@xuanwo.io>
2026-11-30 16:49:51 +08:00
Jack Ye 9a79107651 chore: align Lance revision for strict FTS prewarm 2026-11-29 18:38:40 -08:00
Jack Ye 9e3af3625d docs(sql): document text and JSON descriptions
Apply the reviewed DESCRIBE TEXT and JSON contract.
2026-11-27 19:02:17 -08:00
Xuanwo c55eaae0dc fix: explain Function catalog SDK compatibility errors (#5250)
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.
2026-11-28 08:30:52 +08:00
Xuanwo 6283f83a92 fix(python): preserve omitted Function GPU counts (#5249)
`@function(gpu=True)` currently serializes `gpus_per_worker: 1` even
when the caller omits `gpu_count`. This prevents registration on servers
that support single-GPU Functions but reject an explicit GPU count
field.

Preserve omission through registration and runtime digest calculation.
The effective default is still one GPU per worker. With an explicit
`gpu_count=1` or `gpu_count=2`, the request and digest include the
declared count. As a result, the omitted and explicit-one forms now have
distinct runtime digests even though both request one GPU in practice.

The regression test captures the Flight SQL `CREATE FUNCTION` request
for CPU, omitted GPU count, and explicit counts of one and two. Only the
omitted-count case failed on the base revision. All 34 focused Python
tests and Ruff checks passed on the candidate Python source with a
compatible native extension. Local replay of the captured requests
against the registration admission code confirmed that the older
implementation accepts the omitted count and that the current
implementation resolves the four effective counts to 0, 1, 1 and 2.
2026-11-28 08:14:36 +08:00
Xuanwo e185dc8646 perf: raise the default Blob V2 direct-read threshold to 32 MiB (#5248)
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.
2026-11-28 03:21:37 +08:00
Xuanwo 129028f300 perf: improve presigned Blob V2 reads (#5247)
## 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.
2026-11-28 02:29:31 +08:00
Lance Release fdc8041b2a Bump version: 0.42.0-beta.37 → 0.42.0-beta.38 v0.42.0-beta.38 2026-11-27 09:41:44 +00:00
LanceDB Robot 6acc3b6d91 chore: update lance dependency to v16.0.0-beta.5 2026-11-27 01:39:42 -08:00
Bilal Atique 09beba532e feat(node): accept Expr values in select() (#4878)
Closes #3042.

Node `select()` now takes `Expr` values, the same expression builder
that `where()` already accepts. A `Map` or a plain object can mix `Expr`
values and SQL strings:

```ts
import { col } from "@lancedb/lancedb";

const rows = await table
  .query()
  .select({
    id: "id",
    name: col("firstName"),
    total: col("unitPrice").mul(col("quantity")),
  })
  .toArray();
```

This works on every query with `select()`: `query()`, `vectorSearch()`,
`search()` and the take queries. The parameter type is now `Map<string,
string | Expr>` and `Record<string, string | Expr>`. Nothing else in the
TypeScript API changes.

### How it works

`select()` turns each `Expr` into SQL with `toSql()` and passes the
pairs to the native `select` that SQL strings already use. `where()`
handles an `Expr` the same way, so Node treats expressions alike in both
places. `toSql()` quotes camelCase names and SQL keywords with
backticks, so `col("firstName")` reads `firstName`.

I also looked at passing the expressions to Rust as `Select::Expr`, as
Python's `select_expr` does. I didn't go that way:

- Before a local or remote query runs, Rust turns `Select::Expr` back
into SQL with the same `expr_to_sql_string`. The query is the same
either way.
- A map that mixes SQL strings and expressions can't become a
`Select::Expr` without parsing the strings. Python's `AsyncQuery.select`
sends a mixed dict through `select_expr` and wraps each string with
`lit()` (`_coerce`), so `select({"id": "id", "doubled": col("score") *
lit(2)})` returns the string `'id'` in the `id` column. Sending SQL
keeps every string a SQL expression.
- I found one path that accepts `Select::Expr` and rejects
`Select::Dynamic`: namespace `QueryTable` pushdown. Node can't turn
pushdown on today, so nothing changes yet. If Node gets that option,
`select()` can send `Select::Expr` when every value is an `Expr`.

`blobMode: "bytes"` (#4353) finds blob columns by name in the `[output,
source]` list of the selection. For a camelCase column, `toSql()` gives
`` `imageData` ``, which doesn't match `imageData`. So when an `Expr` is
a bare column reference, the match uses its plain name. For this, the
native `Expr` gets a small `columnName()` helper, like `column_name()`
in the Python bindings, which Python uses for the same match. A blob
renamed with `col()` gets its bytes, as with a SQL string. Other
expressions are not filled with bytes, as before.

A value that is neither a string nor an `Expr` now throws a `TypeError`
that names the key, instead of the native conversion error.

### Tests

New tests in `expr.test.ts`:

- a `Map` that mixes SQL strings with `col("firstName")` and
`col("unitPrice").mul(2)` on a plain query, with the column order
- a `Record` with `upper()`, `func("lower", ...)` and a SQL string,
filtered with an `Expr` in `where()`
- `Expr` values on a vector query, an automatic `search()` (full-text
search) and a take query
- `blobMode: "bytes"` with a camelCase blob column selected with
`col()`: renamed, next to a computed `Expr` column, and in a take query
- a number as a value throws a `TypeError`

The whole Node suite passes. The Node docs under `docs/src/js` are
regenerated. The `@example` in the middle of the `select()` docstring
used to swallow the two paragraphs after it into the code block, so I
moved the example to the end, which is why each query class page
changes.

Left out: `Expr` items in the plain column list (`select([col("a")])`),
because an expression needs an output name. The `select` of a
materialized view still takes SQL strings only.
2026-11-27 17:10:43 +08:00
Henry Su fdfbb98a9c fix(python): give tied FTS scores full weight in hybrid normalization (#4858)
## Why

Hybrid search normalizes FTS scores with min-max. When all FTS scores
are equal (one match, or a tie), the range is 0 and every score became
0. `LinearCombinationReranker` treats 0 as a missing FTS match. So a
lone keyword match could rank below documents without the keyword. Fixes
#4857.

## What changed

- `_normalize_scores` takes a `tie_value` for the zero-range case. The
default stays 0, so vector distances are unchanged.
- The FTS leg passes `tie_value=1.0`, so tied FTS matches count as the
best FTS result.

## Scope

- Covers the zero-range case for both `normalize="score"` and
`normalize="rank"`.
- Leaves out how `_rank` breaks ties among equal scores. That is a
separate question.

## Blast Radius

The change only affects hybrid queries where every FTS hit has the same
score. RRF and MRR use list position, so their results don't change.
LinearCombination and custom score-based rerankers now give those hits
full FTS weight.

## Verification

- A new test in `test_hybrid_query.py` fails on main in both normalize
modes and passes with the fix.
- `pytest python/tests -m "not slow and not s3_test"`: 3272 passed, 167
skipped.
- `ruff format --check` and `ruff check` (0.9.9, the version pinned by
pre-commit) pass.
2026-11-27 16:23:03 +08:00
lancedb-gatefixer[bot] 0736ef02b0 fix: reject merge inserts on version-pinned tables (#4851)
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>
2026-11-27 15:50:37 +08:00
lancedb-gatefixer[bot] a663417fa9 fix: validate remote tag checkout branch and version (#4853)
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>
2026-11-27 15:50:20 +08:00
Lance Release e38d8bef56 Bump version: 0.42.0-beta.36 → 0.42.0-beta.37 v0.42.0-beta.37 2026-11-27 03:36:01 +00:00
LanceDB RobotandXuanwo 344a4d1444 chore: update lance dependency to v16.0.0-beta.4 (#5242)
Update the Rust and Java Lance dependencies to
[v16.0.0-beta.4](https://github.com/lance-format/lance/releases/tag/v16.0.0-beta.4)
and pin Python tests to pylance 16.0.0b4. Make the Node.js Rust blob
parser helper private so strict workspace Clippy passes.

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
2026-11-27 11:34:27 +08:00
Jack Ye b53bbd0bca fix(sql)!: request JSON for storage integration descriptions
Apply the reviewed storage integration change.
2026-11-26 17:31:51 -08:00
Jack Ye 8685809218 fix(sql)!: request JSON for secret descriptions
Apply the reviewed secret change.
2026-11-26 17:31:05 -08:00
Jack Ye 00fc309a85 fix(sql)!: request JSON for function descriptions
Apply the reviewed function change.
2026-11-26 17:30:50 -08:00
Jack Ye 4498be55f5 fix(sql)!: request JSON for materialized view descriptions
Apply the reviewed materialized view change.
2026-11-26 17:30:32 -08:00
Jack Ye a8971c1811 fix(sql)!: request JSON for view descriptions
Apply the reviewed view change.
2026-11-26 17:29:44 -08:00
Xuanwo 1c0118015c feat(nodejs): open source-bearing blob descriptors (#5238)
Add `Table.openBlobFile` and `Table.openBlobFiles` for source-bearing
SQL `blob_descriptor` results, matching the existing Rust and Python
APIs.

The TypeScript methods forward the descriptor to the shared Rust opener
instead of reimplementing routing. That keeps the 10 MiB direct-read
threshold, pinned snapshot identity, resolver refresh, and 503
single-shot proxy fallback identical to `fetchBlobFiles` and the other
public Blob V2 entries. Descriptor fields remain the snake_case shape
returned by Arrow/SQL; the wrapper converts unsigned 64-bit values to
`bigint` at the NAPI boundary and returns `null` for null descriptors.
Existing custom `Table` subclasses keep working through a default "not
supported" implementation.

Validation:
- `pnpm tsc`
- `pnpm lint`
- `pnpm test --runInBand __test__/blob_open.test.ts
__test__/blob_ranges.test.ts __test__/remote_blob_snapshot.test.ts` — 65
passed
- focused Rust core tests for direct opens, threshold routing, snapshot
preservation, and 503 fallback — passed

The docs also update the TypeScript cross-row range table and example;
`fetchBlobRanges` was already implemented but was still documented as
unavailable.
2026-11-27 00:16:29 +08:00
Lance Release 85dcf3a3c5 Bump version: 0.42.0-beta.35 → 0.42.0-beta.36 v0.42.0-beta.36 2026-11-26 15:06:40 +00:00
LanceDB Robot 2b193cc6ea chore: update lance dependency to v16.0.0-beta.3 (#5237)
Update Rust and Java dependencies to [Lance
v16.0.0-beta.3](https://github.com/lance-format/lance/releases/tag/v16.0.0-beta.3).
Pin Python tests to pylance 16.0.0b3 and refresh the lockfile.
2026-11-26 23:05:33 +08:00
Xuanwo 2806709b75 fix(ci): hand off Pages artifact to a separate deploy job (#5236)
The docs workflow uploads `github-pages` and deploys in the same job. On
`0adfd22`, attempt 1 finished the upload and the deploy immediately
found zero artifacts; attempt 2 uploaded again and the deploy found two
artifacts with the same name. Four earlier main runs show the same
zero-artifact race.

This uploads the site as `github-pages-<run_id>-<run_attempt>`, exposes
that name as a `build` job output, and deploys from a separate `needs:
build` job using the same name. A full workflow re-run gets a fresh
name, while a deploy-only retry keeps the original build output and
reuses the artifact uploaded by that build.

The existing action pins already expose the required inputs (`name` on
`upload-pages-artifact`, `artifact_name` on `deploy-pages`), so this
does not bump actions. Workflow triggers, permissions, concurrency, docs
build steps, and the Pages environment URL are unchanged.

Validation: `actionlint .github/workflows/docs.yml`, YAML parsing, and
`git diff --check` pass locally. Hosted checks run on this PR; the
actual Pages upload and deploy are verified on main after merge because
the workflow only deploys from `main`.

Evidence:
- [attempt
1](https://github.com/lancedb/lancedb/actions/runs/45805006874/job/139857949931):
upload succeeded, deploy logged `Found 0 artifact(s)`.
- [attempt
2](https://github.com/lancedb/lancedb/actions/runs/45805006874/job/139875545904):
upload succeeded, deploy logged `Found 2 artifact(s)` and failed with
`Multiple artifacts named "github-pages" were unexpectedly found`.
- Earlier main runs with the same zero-artifact result:
[45724226049](https://github.com/lancedb/lancedb/actions/runs/45724226049),
[45706607284](https://github.com/lancedb/lancedb/actions/runs/45706607284),
[45700962558](https://github.com/lancedb/lancedb/actions/runs/45700962558),
[45687315855](https://github.com/lancedb/lancedb/actions/runs/45687315855).
2026-11-26 20:24:14 +08:00
Lance Release 0adfd22db1 Bump version: 0.42.0-beta.34 → 0.42.0-beta.35 v0.42.0-beta.35 2026-11-26 10:50:09 +00:00
LanceDB Robot c54d15ada1 chore: update lance dependency to v16.0.0-beta.2 (#5234)
Bump the Rust and Java Lance dependencies to v16.0.0-beta.2 and
synchronize the Python pylance requirements and lockfile with 16.0.0b2.

[Lance v16.0.0-beta.2
release](https://github.com/lance-format/lance/releases/tag/v16.0.0-beta.2)
2026-11-26 10:48:43 +00:00
Lance Release 9adb403656 Bump version: 0.42.0-beta.33 → 0.42.0-beta.34 v0.42.0-beta.34 2026-11-26 03:33:13 +00:00
Xuanwo 4a5c4a84a9 fix(python): preserve the requested package index on Function inspection (#5220)
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.
2026-11-26 11:31:43 +08:00
Lance Release 7c3d68e951 Bump version: 0.42.0-beta.32 → 0.42.0-beta.33 v0.42.0-beta.33 2026-11-25 23:49:08 +00:00
Xuanwo cb7f1bad67 feat(rust): open a native table at a retained version (#5218)
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.
2026-11-26 06:11:51 +08:00
Lance Release 7e1478b547 Bump version: 0.42.0-beta.31 → 0.42.0-beta.32 v0.42.0-beta.32 2026-11-25 21:41:10 +00:00
LanceDB RobotandXuanwo 17532bb8c3 chore: update lance dependency to v15.1.0-beta.2 (#5217)
Bump the Rust workspace and Java Lance dependencies to [Lance
v15.1.0-beta.2](https://github.com/lance-format/lance/releases/tag/v15.1.0-beta.2)
and pin the matching `pylance` beta in the Python test extra.

Raise the Rust toolchain and minimum supported version to 1.98.0 as
required by Lance, and address the new Clippy diagnostics.

Co-authored-by: Xuanwo <github@xuanwo.io>
2026-11-26 05:39:46 +08:00
Lance Release 8441dab874 Bump version: 0.42.0-beta.30 → 0.42.0-beta.31 v0.42.0-beta.31 2026-11-25 21:32:03 +00:00
LanceDB RobotandXuanwo da6aa8c779 chore: update lance dependency to v15.1.0-beta.1 (#5213)
Update the Rust workspace and Java dependencies to [Lance
v15.1.0-beta.1](https://github.com/lance-format/lance/releases/tag/v15.1.0-beta.1).
Pin the Python test extra to the matching pylance 15.1.0b1 release and
refresh the lockfile.

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
2026-11-25 13:30:32 -08:00
Xuanwo 3d558adc68 fix(remote): preserve blob snapshot identity across credential refresh (#5216)
## What

Fix the refresh path for direct Blob handles opened from a SQL
`blob_descriptor`.

`open_blob_file` acquired the resolver's immutable snapshot identity,
but the `PresignedBlobRangeRequester` used
`blob_locations_context_for_source`, which only copied the table
handle's `expected_query_snapshot`. For an ordinary table handle that is
`None`, so a provider credential expiry and refresh could establish a
different identity at the same numeric version. The refreshed handle
could then accept replacement-table bytes.

The refresh context now carries the identity acquired by the first
resolver response, matching the whole-read, range-read and
`fetch_blob_files` paths.

## Coverage

Adds five focused tests through the normal `open_blob_file` entrypoint:

- proactive refresh inside the 30s expiry skew before any object GET;
- provider credentials expiring earlier than the advertised URL TTL
(far-future `expires_at`, object store returns 403);
- single-shot re-resolution: a second 403 after refresh fails without a
third resolver call;
- renewal with a different snapshot identity is rejected before
accepting bytes;
- renewal resolver `403` propagates as an auth failure.

Existing `direct_blob_file_refreshes_expired_url_once` covered only
reactive refresh with no advertised expiry.

## Signer contract

The SDK treats object-store `401`/`403` as expiry and refreshes once. If
the resolver signs the refreshed URL with still-expired provider
credentials, the second object GET fails and the SDK fails closed.
Signers should return an `expires_at` no later than the underlying
credential expiry and use renewed credentials on re-resolution.

## Validation

- `cargo test -p lancedb --quiet --features remote --lib
remote::table::blobs::tests`: 70 passed.
- `cargo check -p lancedb --quiet --features remote --tests`: run before
the final test pass.
- No Sophon signer or cloud resource changes.
2026-11-26 05:04:38 +08:00
Bruno Ramirez 06e626238d feat(cli): package release binaries as lancedb-tools wheels (#5214)
Python users can install the LanceDB SDK today. This adds a separate
`lancedb-tools` distribution so they can also run the standalone
`lancedb` CLI with `uvx` or install it with `pipx`. The wheels bundle
the same binaries shipped through GitHub Releases for Apple Silicon
macOS, Linux ARM64, and Linux x86-64. The workflow uploads the wheels to
GitHub Actions for testing. PyPI publication will wait for a stable
release.

This was accomplished with the following changes:

- Verify the release archives against `SHA256SUMS` and bundle each
binary with its license and third-party notices in a platform-specific
wheel.
- Add the `lancedb` entry point and document how to build and test
wheels from a release tag.
- Exercise each wheel with both `uvx` and `pipx` on a native runner.

### Testing

All six installation checks passed against `v0.42.0-beta.30` (Python
version `0.42.0b30`). On Apple Silicon macOS, Linux ARM64, and Linux
x86-64, both `uvx` and `pipx` reported `lancedb 0.42.0-beta.30` and
listed the built-in local profile. [Native test results and wheel
artifacts](https://github.com/lancedb/lancedb/actions/runs/45680764524)

Locally verified that all three wheels contain byte-for-byte copies of
the released binary and license notices. All 38 tests in `ci/tests`
discovered by Python unittest passed.
2026-11-25 11:39:12 -08:00
Xuanwo 60519d42ce feat(remote): add presigned direct Blob V2 reads (#5210)
## What

Add a capability-gated client path for large Blob V2 reads over LanceDB
Enterprise:

- A successful `describe` advertises `x-lancedb-blob-locations: 1`; the
SDK then resolves pinned row locations through `POST
/v1/table/{id}/blob_locations/`.
- Whole reads (`fetch_blobs`) and seekable handles (`fetch_blob_files` /
`open_blob_file`) read presigned object-store URLs directly for eligible
values and ranges at or above a provisional internal 10 MiB threshold.
- Small ranges and `fetch_blob_ranges` stay on the existing proxy path,
including aggregate batches whose total exceeds the proxy byte limit.
- Shared `Packed` / `Managed` sidecars translate logical ranges to
physical offsets and validate the full numeric `Content-Range` tuple,
not just its start or total.
- Presigned traffic uses a separate HTTP client with no Enterprise
default headers, so service credentials never reach object storage.
- The first resolver response must carry a valid query-snapshot
identity. That identity is then required on every later partition and
preserved through object-URL refresh, proxy fallback and oversized
whole-value recovery. A resolver `503` falls back once to the proxy path
using any version and identity already pinned; other resolver errors
propagate. Object-store `503`s do not masquerade as resolver
unavailability.
- A read that starts without the capability reuses its supplied
`ReadSnapshot` if a later describe enables direct opening mid-operation.
- Version and query-snapshot pinning, NULL/order alignment and empty
values are preserved.

## Client network requirement

On Enterprise clusters that enable direct Blob reads, large values and
individual ranges may be fetched from short-lived object-store URLs
instead of the LanceDB proxy. Clients then need network access to the
object-store endpoint, including private endpoint routing, DNS, TLS
trust and egress rules, in addition to the LanceDB endpoint. Small reads
stay on the LanceDB proxy.

## Why

Large Blob V2 reads currently stream every payload byte through `Object
Store -> Plan Executor -> Query Node -> client`. That consumes internal
bandwidth, inflates PE/QN memory use and pollutes executor caches with
low-locality `.blob` data. This is the SDK half of ENT-4358; the server
implementation is in Sophon.

## Compatibility

No public SDK signatures change. Old clusters omit the capability header
and keep the existing proxy behaviour with zero extra round trips. The
10 MiB threshold is an internal prototype choice pending the paired
acceptance measurement; it is not a public knob.

## Validation

- `cargo check -p lancedb --quiet --features remote --tests` passes.
- `cargo test -p lancedb --quiet --features remote --lib
remote::table::blobs::tests` passes: 65 tests.
- New coverage includes direct whole reads, shared-sidecar physical
offsets and Content-Range rejection, small-range proxy routing, mixed
large/small range batches, resolver `503` fallback with pinned state, no
second resolver after fallback, object-store `503` not triggering proxy
fallback, missing/mismatched resolver identity rejection, resolver
identity preservation through refresh/proxy/oversized recovery,
supplied-snapshot reuse on mid-operation capability refresh, and
NULL/order/null-preserving paths.

A real-QN acceptance run with the candidate SDK binary is separate and
still pending deployment of the candidate server image.
2026-11-26 03:16:25 +08:00