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
+6 -2
View File
@@ -1895,17 +1895,19 @@ impl Table {
})
}
#[pyo3(signature = (columns=None, *, filter=None, concurrency=None))]
#[pyo3(signature = (columns=None, *, filter=None, concurrency=None, parameters=None))]
pub fn prewarm_data_async<'py>(
self_: PyRef<'py, Self>,
columns: Option<Vec<String>>,
filter: Option<String>,
concurrency: Option<&Bound<'py, PyAny>>,
parameters: Option<PyArrowType<arrow::record_batch::RecordBatch>>,
) -> PyResult<Bound<'py, PyAny>> {
let inner = self_.inner_ref()?.clone();
let mut options =
lancedb::table::PrewarmDataOptions::new().columns(columns.unwrap_or_default());
options.filter = filter;
options.parameters = parameters.map(|parameters| parameters.0);
options.concurrency = positive_u32_integer(concurrency, "concurrency")?;
future_into_py(self_.py(), async move {
let job = inner.prewarm_data_async(options).await.infer_error()?;
@@ -1913,17 +1915,19 @@ impl Table {
})
}
#[pyo3(signature = (columns=None, *, filter=None, concurrency=None))]
#[pyo3(signature = (columns=None, *, filter=None, concurrency=None, parameters=None))]
pub fn explain_prewarm_data<'py>(
self_: PyRef<'py, Self>,
columns: Option<Vec<String>>,
filter: Option<String>,
concurrency: Option<&Bound<'py, PyAny>>,
parameters: Option<PyArrowType<arrow::record_batch::RecordBatch>>,
) -> PyResult<Bound<'py, PyAny>> {
let inner = self_.inner_ref()?.clone();
let mut options =
lancedb::table::PrewarmDataOptions::new().columns(columns.unwrap_or_default());
options.filter = filter;
options.parameters = parameters.map(|parameters| parameters.0);
options.concurrency = positive_u32_integer(concurrency, "concurrency")?;
future_into_py(self_.py(), async move {
let plan = inner.explain_prewarm_data(options).await.infer_error()?;