mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-17 01:02:28 +00:00
The function catalogue is now real rather than a pointer. Scalar functions are listed by taxonomy -- math, string, unicode, regex, date/time, array, map, struct, crypto, type -- and the names come from what datafusion-functions 54 actually registers, not from what DataFusion documents on main. Aggregate and window pages gain the same treatment. Two things the audit corrected rather than copied. SHOW TABLES does not work. DataFusion implements it over information_schema, which this session does not enable, so it fails at plan time. It was documented as working here, on the SHOW page and in three Manage tables; all four are fixed, and the SQL overview now lists the absence alongside SHOW COLUMNS. Prepared statements are a Flight SQL protocol feature, not a PREPARE statement. A script carrying PREPARE ... AS SELECT will not run, while the same intent expressed through a client will. The new page says so rather than copying DataFusion's syntax. Every section of the Documentation tab that has a SQL counterpart now links to it -- 27 of 76 non-SQL pages, each pointing at the specific statement rather than at the reference index.
83 lines
2.3 KiB
Plaintext
83 lines
2.3 KiB
Plaintext
---
|
|
title: "Update rows"
|
|
sidebarTitle: "Update"
|
|
description: "Change values in rows that already exist, by predicate or SQL expression."
|
|
icon: pen
|
|
---
|
|
|
|
These examples use the table set up in
|
|
[Ingesting data](/ingestion), and the connection made there.
|
|
|
|
import {
|
|
PyUpdateOperation as UpdateOperation,
|
|
PyUpdateUsingSql as UpdateUsingSql,
|
|
TsUpdateOperation,
|
|
TsUpdateUsingSql,
|
|
RsUpdateOperation,
|
|
RsUpdateUsingSql,
|
|
} from '/snippets/tables.mdx';
|
|
|
|
<Note>
|
|
In SQL this is [`UPDATE`](/sql/dml#update).
|
|
</Note>
|
|
|
|
## Update rows {#update-rows}
|
|
|
|
Use `update` when you already know which target rows to modify and you do not need to compare against an incoming dataset.
|
|
|
|
<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>
|
|
|
|
Expected table contents:
|
|
|
|
| id | name | login_count |
|
|
| --- | --- | --- |
|
|
| 1 | Alice | 10 |
|
|
| 2 | Bobby | 20 |
|
|
|
|
<Warning title="Warning">
|
|
Updating nested columns is not yet supported.
|
|
</Warning>
|
|
|
|
## Update rows with SQL expressions {#update-rows-with-sql-expressions}
|
|
|
|
Use `values_sql` when you want to use SQL-like expressions to update rows. This is useful for operations like incrementing a counter, or setting a column value based on another column.
|
|
|
|
<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>
|
|
|
|
Expected table contents:
|
|
|
|
| id | name | login_count |
|
|
| --- | --- | --- |
|
|
| 1 | Alice | 10 |
|
|
| 2 | Bob | 21 |
|
|
|
|
<Note title="SQL syntax">
|
|
See the [SQL queries](/search/sql/) page for more information on the supported SQL syntax.
|
|
</Note>
|
|
|
|
When rows are updated, they are moved out of any existing index. The row will still show up in search queries, but the query will not be as fast as it would be if the row was in the index. If you update a large proportion of rows, consider triggering an index rebuild afterwards.
|