Skip to main content

Update

Change column values in the rows of a Delta table that match a predicate. Run it in a SQL paragraph, or in a Magpie paragraph as sql(UPDATE …). See Changing Table Data with SQL for where DML runs, which tables accept it, and worked examples.

Syntax​

UPDATE <table> [[AS] <alias>]
SET [<alias>.]<column> = <expression> [, ...]
[WHERE <predicate>]

Parameters​

table​

String — The Delta table to update, as table or schema.table, in the current repository.

alias​

String — Optional. A name for the table within the statement. If you give the table an alias, qualify columns with the alias (UPDATE sales.orders o SET o.status = …), not the table name. Without an alias, the table name works as a qualifier.

column and expression​

String, expression — The column to change and its new value. The expression can refer to the row's current values.

predicate​

Expression — Optional. The rows to change. Without WHERE, every row is updated.

Supported tables​

Delta tables only.

Examples​

UPDATE sales.orders
SET status = 'shipped', shipped_at = current_timestamp()
WHERE order_id = 1234

Errors​

Besides the common DML errors:

MessageCause
<statement> is only supported on Delta tables for file-backed targets; "<table>" uses <format>.The table is on a file format other than Delta.
<statement> is not supported for table "<table>" (connector: <type>). The <type> Spark connector supports scans and batch writes, not the row-level operations Spark DML requires; row-level DML requires a Delta table.The table is connector-backed.
DML target '<table>' cannot be used as a column-reference qualifier (e.g., '<table>.col'). Attach an alias to the target and reference the alias instead (e.g., 'UPDATE <table> t SET t.col = ...').The table has an alias, but a column in SET or WHERE is qualified with the table name.

Security​

Requires Write permission on the table, and Read permission on any other table the statement reads.

Lineage​

An update reads no other table, so Describe shows it only as the table's last write.