fix(python): explain blob descriptor copy guidance (#5060)

The descriptor-copy error only named the missing `data`/`uri` child. It
now says that this shape is an SDK blob descriptor rather than payload
bytes, and points to `blob_mode="bytes"` for supported materialization,
`blob_mode="descriptions"` for inspection, and the row-id plus
`fetch_blobs`/`fetch_blob_files` copy path while the source stays
unchanged.

This reuses the merged guidance from #4940 and the
direct-materialization contract from #4973. Ray integration remains out
of scope for ENT-3556.

Refs ENT-3556

Test: `python/tests/test_blob.py` (210 passed, 39 skipped), including a
regression that writes default lazy descriptor rows into a blob-schema
table, checks the guidance, and confirms no target is created.
`python/tests/test_util.py -k blob` (12 passed, 2 skipped).
This commit is contained in:
Xuanwo
2026-11-16 18:56:39 +08:00
committed by GitHub
parent 2ab103d775
commit c7d972fe48
2 changed files with 26 additions and 1 deletions
+18
View File
@@ -1135,6 +1135,24 @@ def test_copy_blob_subset_preserves_payloads_nulls_and_empty_values(tmp_path):
assert sorted(copied, key=lambda row: row["id"]) == rows[:3]
def test_copy_blob_descriptor_rows_explains_payload_materialization(tmp_path):
db = lancedb.connect(tmp_path)
schema = pa.schema([pa.field("id", pa.int64()), lancedb.blob("image")])
source = db.create_table("source", data=[{"id": 1, "image": b"one"}], schema=schema)
hits = source.search().where("id = 1").to_arrow()
with pytest.raises(ValueError, match="must contain a 'data' or 'uri' child") as exc:
db.create_table("copy", data=hits, schema=schema)
message = str(exc.value)
assert "blob_mode='bytes'" in message
assert "blob_mode='descriptions'" in message
assert "with_row_id(True)" in message
assert "fetch_blobs(column, row_ids)" in message
assert "fetch_blob_files(column, row_ids)" in message
assert not db.table_exists(["copy"])
def test_fetch_blobs_round_trip():
table = _blob_table(
"round_trip",