mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-02 16:56:52 +00:00
## Summary Adopts the product terminology guide across the docs site pages, SDK docstrings and error messages. "LanceDB OSS" and local mode become **LanceDB Embedded**. "Remote" as the execution model becomes **LanceDB Distributed**, which LanceDB Enterprise provides. Where free vs paid is the point, pages contrast "LanceDB Embedded (open source)" with "LanceDB Enterprise". This is a first trial of the Embedded name, so reviewers can judge it in context. - **Embedded vs Distributed** for where execution runs (`optimize()`, consistency, branching, maintenance). Main pages define it once: "LanceDB Enterprise runs LanceDB Distributed: …" - **LanceDB Cloud** is kept only for legacy-Cloud specifics (`db://` region, the brute-force KNN limit) and marked legacy. "Cloud and Enterprise" becomes Enterprise or Distributed. - **Plan executor** becomes "executor" or the fleet name. - **Error messages** change, e.g. `optimize is not supported for remote tables.` → `... in LanceDB Distributed.` Tests that match on them are updated. - **Vale rules** (`EmbeddedName`, `OSSProduct`, `RemoteExecution`, `DistributedEnterprise`, `LegacyCloud`, `InternalNames`) enforce the terms in prose. Unchanged: identifiers (`availability.oss`, the `remote` module and feature, `RemoteTable`, `db://`), heading anchors, internal code comments, and Geneva. ## Evidence - Rust lib tests for the changed messages and the Python tests in `test_remote_db.py`, `test_materialized_views.py` and `test_table.py` pass locally. - Not run locally: - The Node tests: `remote.test.ts` and `table.test.ts` have updated assertions. - Vale. - The `experimental_functions`-marked materialized-view tests. - `docs/src` API reference was hand-edited to match the docstrings rather than regenerated. ## Merge Risk **Door:** two-way; prose and message text only. **Blast Radius:** `docs`, `error-messages`: callers matching on old error strings would break. Companion PRs: lancedb/docs (assembler labels, STYLE.md) and sophon (Enterprise pages). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
4.6 KiB
Plaintext
124 lines
4.6 KiB
Plaintext
---
|
|
title: "Update rows"
|
|
sidebarTitle: "Update"
|
|
description: "Select existing rows, change values or expressions, and verify the changes."
|
|
icon: pen
|
|
availability:
|
|
oss: available
|
|
enterprise: available
|
|
summary: >-
|
|
Update rows through the SDKs in LanceDB Embedded and LanceDB Enterprise. Enterprise also supports the SQL UPDATE statement.
|
|
---
|
|
|
|
import {
|
|
TsUpdateOperation,
|
|
TsUpdateUsingSql,
|
|
RsUpdateOperation,
|
|
RsUpdateUsingSql,
|
|
} from '/snippets/tables.mdx';
|
|
import {
|
|
PyUpdateOperation as UpdateOperation,
|
|
PyUpdateUsingSql as UpdateUsingSql,
|
|
} from '/snippets/ingestion_examples.mdx';
|
|
|
|
import { PyWriteWorkflow, TsWriteWorkflowBody, TsWriteWorkflowTail, RsWriteWorkflow } from '/snippets/ingestion_examples.mdx';
|
|
|
|
Use `update` to change rows selected by a predicate. Use
|
|
[merge insert](/ingestion/merge-insert) instead when matching an incoming dataset
|
|
against existing keys.
|
|
|
|
## Select the rows to change {#select-rows}
|
|
|
|
Check the predicate with a [filtered query](/search/filtering) before applying
|
|
the update. These examples target the row with `id = 2`. Review the scope
|
|
carefully when omitting a predicate, since that can update the entire table.
|
|
|
|
Each example below starts from Alice with 10 logins and Bob with 20. The
|
|
Python programs create and remove their own temporary database. TypeScript
|
|
and Rust operation blocks use `db`; a complete program is provided below.
|
|
|
|
## Assign a new value {#update-rows}
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="python" icon="python">
|
|
{UpdateOperation}
|
|
</CodeBlock>
|
|
<CodeBlock filename="TypeScript" language="typescript" icon="square-js">
|
|
{TsUpdateOperation}
|
|
</CodeBlock>
|
|
<CodeBlock filename="Rust" language="rust" icon="rust">
|
|
{RsUpdateOperation}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
The result contains Alice and **Bobby**, with their login counts unchanged.
|
|
The Python `values` and TypeScript `values` arguments take literal values.
|
|
Rust's `column` argument is an expression, so the string value includes SQL quotes.
|
|
|
|
## Calculate a value from the existing row {#update-rows-with-sql-expressions}
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="python" icon="python">
|
|
{UpdateUsingSql}
|
|
</CodeBlock>
|
|
<CodeBlock filename="TypeScript" language="typescript" icon="square-js">
|
|
{TsUpdateUsingSql}
|
|
</CodeBlock>
|
|
<CodeBlock filename="Rust" language="rust" icon="rust">
|
|
{RsUpdateUsingSql}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
In this separate example, Bob keeps his name and his login count becomes **21**.
|
|
Python's `values_sql` and TypeScript's `valuesSql` accept expressions.
|
|
These SDK expressions work with LanceDB Embedded tables; they do not require an
|
|
Enterprise SQL endpoint. Enterprise also offers [`UPDATE`](/sql/dml/update).
|
|
|
|
## Verify the affected data {#verify}
|
|
|
|
Read the selected rows again and inspect the changed fields. For another
|
|
connection or table handle, account for its
|
|
[read consistency](/tables/consistency) settings.
|
|
|
|
Nested-field updates are not supported by these operations. For schema changes,
|
|
see [schema evolution](/management/table#schema). Treat derived values separately:
|
|
changing an input field is not a guarantee that every stored feature has been
|
|
recomputed. See [Refresh a column](/feature-engineering/refresh-column).
|
|
|
|
Updates can change index coverage and query cost. After a large update,
|
|
inspect the workload and follow [index maintenance](/indexing/reindexing)
|
|
guidance for the backend you use.
|
|
|
|
## Complete write workflow {#complete-example}
|
|
|
|
<Accordion title="Complete examples: create, append, update, upsert and delete">
|
|
|
|
Each program creates a temporary local database, performs the five operations,
|
|
prints the result, and removes its temporary data when finished.
|
|
|
|
- **Python:** install `lancedb`, save the code as `ingestion.py`, and run
|
|
`python ingestion.py`.
|
|
- **TypeScript:** install `@lancedb/lancedb`, save the code as `ingestion.mts`,
|
|
and run `node ingestion.mts` with Node.js 22.18 or later.
|
|
- **Rust:** download the [complete Rust project](/static/code/ingestion-rust.zip),
|
|
extract it, and run `cargo run --locked`. It includes `src/main.rs`, the Cargo
|
|
manifest and a lockfile for the example's dependencies. The code is shown below.
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="ingestion.py" language="python" icon="python">
|
|
{PyWriteWorkflow}
|
|
</CodeBlock>
|
|
<CodeBlock filename="ingestion.mts" language="typescript" icon="square-js">
|
|
{TsWriteWorkflowBody}
|
|
{TsWriteWorkflowTail}
|
|
</CodeBlock>
|
|
<CodeBlock filename="src/main.rs" language="rust" icon="rust">
|
|
{RsWriteWorkflow}
|
|
</CodeBlock>
|
|
</CodeGroup>
|
|
|
|
After the operations, Alice has 10 logins, Bobby has 21, and Charlie has 6.
|
|
Dana is selected for deletion and is absent from the final result.
|
|
|
|
</Accordion>
|