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).
This commit is contained in:
Xuanwo
2026-11-20 23:47:26 +08:00
committed by GitHub
parent d46754cad4
commit a2176f9bcd
10 changed files with 353 additions and 39 deletions
+12
View File
@@ -915,6 +915,18 @@ with `search().with_row_id(True).to_arrow()` and pass the result to the fetch AP
One missing or deleted row ID rejects the entire blob-read batch; the APIs do
not return partial results.
Row positions are not row IDs. To read by position, call
`take_offsets(offsets, with_row_id=True)` first and pass the resulting `_rowid`
values; `fetch_blobs` remains row-ID based. A query result table that carries
snapshot metadata keeps the snapshot that produced it on LanceDB Enterprise, so
the fetched bytes or files stay pinned if the table changes. Metadata-free
inputs, including legacy query responses and plain row-ID lists, are read from
the table handle's current snapshot; keep the source unchanged between selection
and fetching. Partial snapshot metadata fails explicitly. For `fetch_blob_files`,
a snapshot-bound read also fails explicitly when the serving node cannot echo
the immutable identity. The basic remote Blob API floor (server 0.5.0) does not
by itself provide that echo capability.
Local and remote `BlobFile` handles prefetch 512 KiB for sequential reads by
default. Pass `buffer_size=0` to `fetch_blob_files`, `open_blob_file`, or
`open_blob_files` for sparse reads, or choose another window size in bytes.