fix(python): explain explicit blob reads and subset copies (#4940)

Unsupported remote blob materialization errors now point to row-ID
selection, fetch_blobs and fetch_blob_files. Document descriptor
structs, fetched bytes and Function BlobReader inputs, and show a
bounded subset-copy recipe that keeps the source unchanged between
selection and fetching.

Adds guidance assertions and copy coverage preserving payloads, empty
blobs and nulls.

No new blob materialization API is introduced.

Formatting applied; no local builds or tests were run. CI will execute
the regression coverage.
This commit is contained in:
Jack Ye
2026-11-10 08:24:32 -08:00
committed by GitHub
parent 3bfa023375
commit 481e82293e
5 changed files with 97 additions and 4 deletions
+33 -1
View File
@@ -1070,8 +1070,10 @@ def test_bytes_mode_refused_under_namespace_query_pushdown(tmp_path):
)
table.add([{"id": 1, "image": b"one"}])
with pytest.raises(NotImplementedError, match="stable table snapshot"):
with pytest.raises(NotImplementedError, match="stable table snapshot") as exc:
table.to_arrow(blob_mode="bytes")
assert "fetch_blobs(column, row_ids)" in str(exc.value)
assert "with_row_id(True)" in str(exc.value)
with pytest.raises(NotImplementedError, match="stable table snapshot"):
table.search().to_list(blob_mode="bytes")
with pytest.raises(NotImplementedError, match="stable table snapshot"):
@@ -1103,6 +1105,36 @@ async def test_async_bytes_mode_refused_under_namespace_query_pushdown(tmp_path)
await table.query().to_batches(blob_mode="bytes")
def test_copy_blob_subset_preserves_payloads_nulls_and_empty_values(tmp_path):
db = lancedb.connect(tmp_path)
schema = pa.schema([pa.field("id", pa.int64()), lancedb.blob("image")])
rows = [
{"id": 1, "image": b"one"},
{"id": 2, "image": b""},
{"id": 3, "image": None},
{"id": 4, "image": b"excluded"},
]
source = db.create_table("source", data=rows, schema=schema)
hits = (
source.search()
.where("id < 4")
.select(["id"])
.with_row_id(True)
.limit(100)
.to_arrow()
)
payloads = source.fetch_blobs("image", hits["_rowid"]).to_pylist()
subset = db.create_table("subset", schema=schema)
subset.add(
[
{"id": image_id, "image": payload}
for image_id, payload in zip(hits["id"].to_pylist(), payloads, strict=True)
]
)
copied = subset.search().to_list(blob_mode="bytes")
assert sorted(copied, key=lambda row: row["id"]) == rows[:3]
def test_fetch_blobs_round_trip():
table = _blob_table(
"round_trip",