Files
lancedb/docs/web/sql/dql/blob-descriptor.mdx
T
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

70 lines
2.0 KiB
Plaintext

---
title: "BLOB_DESCRIPTOR"
sidebarTitle: "BLOB_DESCRIPTOR"
description: "The blob_descriptor() scalar function: a BlobV2 column's payload location, without reading it."
icon: file-binary
keywords: ["blob_descriptor", "sql", "blob", "large binary", "scalar function"]
availability:
embedded: unavailable
enterprise: available
---
<CodeGroup>
```sql SQL icon="database"
SELECT id, blob_descriptor(video) AS descriptor FROM videos
```
</CodeGroup>
A plain `SELECT` of a [BlobV2](/management/table#managed-blobs) column returns
its payload as `large_binary`. `blob_descriptor` instead returns a small
struct describing where the payload lives, without reading the payload.
Pass one row's descriptor to
the SDK's blob file reader to open that payload directly:
<CodeGroup>
```python Python icon="python"
rows = db.execute_query("SELECT id, blob_descriptor(video) AS descriptor FROM videos").read_all().to_pylist()
with table.open_blob_file(rows[0]["descriptor"]) as reader:
payload = reader.read()
```
```typescript TypeScript icon="typescript"
const rows = await table
.query()
.select({ descriptor: "blob_descriptor(video)" })
.toArray();
const reader = await table.openBlobFile(rows[0].descriptor);
if (reader) {
const payload = await reader.read();
await reader.close();
}
```
```rust Rust icon="rust"
use lancedb::{blob::BlobDescriptor, Table};
async fn read_descriptor(
table: &Table,
descriptor: &BlobDescriptor,
) -> lancedb::Result<()> {
let reader = table.open_blob_file(descriptor).await?;
let payload = reader.read().await?;
println!("{} bytes", payload.len());
reader.close().await?;
Ok(())
}
```
</CodeGroup>
A descriptor is pinned to the table version it was read at: it keeps
resolving correctly even after the table is appended to and checked out to a
newer version.
## What to read next {#next}
<CardGroup cols={2}>
<Card title="Managed blobs" icon="file-binary" href="/management/table#managed-blobs">
The BlobV2 column type this function describes.
</Card>
</CardGroup>