Delete
Remove the rows of a Delta table that match a predicate. Run it in a SQL paragraph, or in a Magpie paragraph as sql(DELETE FROM …). See Changing Table Data with SQL for where DML runs, which tables accept it, and worked examples.
This is the SQL statement. To delete a file from a data source, use Delete Data Source File; to remove a table, use Drop Table.
Syntax
DELETE FROM <table> [[AS] <alias>] [WHERE <predicate>]
Parameters
table
String — The Delta table to delete from, 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 in the predicate with the alias, not the table name. Without an alias, the table name works as a qualifier.
predicate
Expression — Optional. The rows to remove. Without WHERE, every row is deleted.
Supported tables
Delta tables only.
Examples
DELETE FROM sales.orders
WHERE status = 'cancelled' AND order_date < '2025-01-01'
Errors
Besides the common DML errors:
| Message | Cause |
|---|---|
<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'). … | The table has an alias, but the predicate qualifies a column with the table name. |
Security
Requires Write permission on the table, and Read permission on any other table the predicate reads.
Lineage
A delete reads no other table, so Describe shows it only as the table's last write.