feat(sdk): support bound parameters in data prewarm (#5076)

Data prewarm methods accept filter expressions but cannot bind their
values, which forces applications to build literal SQL themselves. This
adds optional positional and named parameters to data-prewarm submission
and typed previews across Rust, Python, and TypeScript. Values use the
existing typed Arrow SQL transport and remain separate from the filter
text. Existing calls and job-handle behavior are preserved;
parameterized filters require a compatible LanceDB Enterprise server.

This was accomplished with the following changes:

- Add `PrewarmDataOptions::parameters(RecordBatch)` and forward the
batch through SQL submission and `EXPLAIN PREWARM` requests.
- Reuse Python's `QueryParameters` conversion for
synchronous/asynchronous, legacy/job-returning, and typed preview
methods.
- Add TypeScript positional-array, named-object, and explicit Arrow
parameter inputs, with safe scalar encoding and native IPC forwarding.
- Keep parameter values out of Rust option debug output and reject
invalid input before submission where possible.
- Add transport and codec regression tests, including injection-shaped
strings, typed Arrow values, legacy method forwarding, and typed preview
bindings.
- Document bound filters in the cache-prewarm guide with Python,
TypeScript, and Rust examples; update generic SQL parameter
documentation.

### Usage and behaviour

```python
job = table.prewarm_data_async(
    ["payload"], filter="id >= $minimum", parameters={"minimum": 1000}
)
job.wait()
```

```typescript
const job = await table.prewarmDataAsync({
  columns: ["payload"], filter: "id >= $1", parameters: [1000],
});
await job.wait();
```

Python accepts a sequence, mapping, or one-row Arrow batch/table.
TypeScript accepts scalar arrays/objects or one-row Arrow input; safe
integers and bigint use Int64, fractional numbers use Float64. Rust
accepts a one-row Arrow batch. Parameters bind filter values, while
table identity, branch, and concurrency keep their existing interfaces.
Submission-only methods also forward bindings and retain their existing
return behavior. Typed preview helpers accept the same parameters
without creating a job.

### Testing

Python prewarm Flight transport tests pass (65 cases), Embedded
compatibility tests pass (6 cases), and focused Node parameter/prewarm
tests pass (45 cases, including ten codec and native-boundary cases).
Earlier matching-server verification passed 57 Python/SQL scenarios, 14
Node scenarios, and Rust SDK checks, covering selective and empty plans,
typed values, authorization, pinned branches, legacy methods, and
injection-shaped strings. A bound job also survives a full runtime
restart. The guide submission examples were also verified in Python,
TypeScript, and Rust; the TypeScript example type-checks. Live-server
checks used filesystem storage.
This commit is contained in:
Bruno Ramirez
2026-11-18 11:07:32 -08:00
committed by GitHub
parent 3907a492c0
commit 23f9d5a741
22 changed files with 613 additions and 50 deletions
+5 -2
View File
@@ -679,7 +679,9 @@ with an unsupported-operation error.
#### Example
```ts
const plan = await table.explainPrewarmData({columns: ["video"], filter: "quality > 0.7"});
const plan = await table.explainPrewarmData({
columns: ["video"], filter: "quality > $minimum", parameters: {minimum: 0.7},
});
console.log(plan.pruning.selectedFragments);
```
@@ -1221,7 +1223,8 @@ the job. After `job.refresh()`, `job.spec.table_version` is the pinned version.
```ts
const job = await table.prewarmDataAsync({
columns: ["video"], filter: "quality > 0.7", concurrency: 4,
columns: ["video"], filter: "quality > $minimum",
parameters: { minimum: 0.7 }, concurrency: 4,
});
await job.wait();
```
+2
View File
@@ -191,6 +191,8 @@
- [JobProgressCallback](type-aliases/JobProgressCallback.md)
- [MaterializedViewSelect](type-aliases/MaterializedViewSelect.md)
- [MultiVector](type-aliases/MultiVector.md)
- [QueryParameterValue](type-aliases/QueryParameterValue.md)
- [QueryParameters](type-aliases/QueryParameters.md)
- [RecordBatchLike](type-aliases/RecordBatchLike.md)
- [SchemaLike](type-aliases/SchemaLike.md)
- [TableLike](type-aliases/TableLike.md)
@@ -37,3 +37,13 @@ optional filter: string;
```
A single SQL predicate for conservative metadata pruning.
***
### parameters?
```ts
optional parameters: QueryParameters;
```
Typed positional or named filter values, sent separately from SQL.
@@ -0,0 +1,20 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / QueryParameterValue
# Type Alias: QueryParameterValue
```ts
type QueryParameterValue:
| string
| number
| bigint
| boolean
| Date
| Uint8Array
| null;
```
Scalar SQL values. Use a one-row Arrow table for explicit Arrow types.
@@ -0,0 +1,16 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / QueryParameters
# Type Alias: QueryParameters
```ts
type QueryParameters: readonly QueryParameterValue[] | Readonly<Record<string, QueryParameterValue>> | TableLike | RecordBatchLike;
```
Values for `$1`/`$name` placeholders, sent separately from SQL text.
Arrays bind by position; objects bind by name. Arrow columns bind both ways.
Safe integers and bigint use Int64; fractional numbers use Float64.
Arrow input preserves explicit types.