mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
test(sdk): align Optimize diagnostics and complete examples
This commit is contained in:
@@ -305,8 +305,25 @@ branch. The server never needs to scan rows merely to evaluate the predicate.
|
||||
options as the job-returning methods but return after acceptance without retaining the handle.
|
||||
The existing TypeScript `prewarmData(columns)` array form remains supported.
|
||||
Rust `prewarm_data()` also accepts the same `PrewarmDataOptions` as durable
|
||||
submission and Explain, including filters and concurrency:
|
||||
submission and Explain. All three convenience methods support columns, filters,
|
||||
and concurrency:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Python">
|
||||
```python
|
||||
table.prewarm_data(["video"], filter="quality > 0.7", concurrency=4)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="TypeScript">
|
||||
```typescript
|
||||
await table.prewarmData({
|
||||
columns: ["video"],
|
||||
filter: "quality > 0.7",
|
||||
concurrency: 4,
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Rust">
|
||||
```rust
|
||||
use lancedb::table::PrewarmDataOptions;
|
||||
|
||||
@@ -315,6 +332,8 @@ table.prewarm_data(PrewarmDataOptions::new()
|
||||
.filter("quality > 0.7")
|
||||
.concurrency(4)).await?;
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Existing Rust `prewarm_data(None)` and `prewarm_data(Some(columns))` calls remain
|
||||
supported. The convenience method returns after acceptance and discards the job
|
||||
|
||||
@@ -576,6 +576,18 @@ await table.optimize(options);
|
||||
const job = await table.optimizeAsync(options);
|
||||
```
|
||||
|
||||
```rust
|
||||
use lancedb::table::OptimizeOptions;
|
||||
|
||||
let options = OptimizeOptions {
|
||||
target_rows_per_fragment: 1000,
|
||||
batch_size: Some(128),
|
||||
..Default::default()
|
||||
};
|
||||
table.optimize(options.clone()).await?;
|
||||
let job = table.optimize_async(options).await?;
|
||||
```
|
||||
|
||||
Python/TypeScript Embedded convenience Optimize also accepts cleanup settings in
|
||||
the same request.
|
||||
Durable Optimize jobs reject cleanup and separate index-maintenance requests before
|
||||
|
||||
@@ -17810,7 +17810,12 @@ mod tests {
|
||||
})
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert!(error.to_string().contains("SQL is unavailable"));
|
||||
assert!(matches!(error, Error::NotSupported { .. }));
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("Optimize jobs require a Flight SQL endpoint")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -17893,9 +17898,9 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
// No SQL client is wired to this REST-only mock, so the branch-scoped
|
||||
// handle hits the same "SQL is unavailable" check `optimize` runs for
|
||||
// main -- it does not reject the branch itself, and it does not send
|
||||
// a REST request (see `test_optimize_requires_sql`).
|
||||
// handle hits the shared missing-endpoint check used on main; it does
|
||||
// not reject the branch itself or send a REST request
|
||||
// (see `test_optimize_requires_sql`).
|
||||
let error = branch
|
||||
.optimize(OptimizeAction::RewriteDataWithOptions {
|
||||
options: crate::table::optimize::OptimizeOptions::default(),
|
||||
@@ -17904,7 +17909,12 @@ mod tests {
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert!(error.to_string().contains("SQL is unavailable"));
|
||||
assert!(matches!(error, Error::NotSupported { .. }));
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("Optimize jobs require a Flight SQL endpoint")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user