Skip to content

Commit

Permalink
docs: delete with the Rust API
Browse files Browse the repository at this point in the history
Signed-off-by: Abdullahsab3 <[email protected]>
  • Loading branch information
Abdullahsab3 committed Jan 4, 2025
1 parent 10949e5 commit af287f5
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions docs/usage/deleting-rows-from-delta-lake-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,29 @@ Suppose you have the following Delta table with four rows:

Here's how to delete all the rows where the `num` is greater than 2:

```python
dt = DeltaTable("tmp/my-table")
dt.delete("num > 2")
```

=== "Python"

```python
dt = DeltaTable("tmp/my-table")
dt.delete("num > 2")
```

=== "Rust"
```rust
let table = deltalake::open_table("./data/simple_table").await?;
let (table, delete_metrics) = DeltaOps(table)
.delete()
.with_predicate(col("num").gt(lit(2)))
.await?;
```
`with_predicate` expects an argument that can be translated to a Datafusion `Expression`. This can be either using the Dataframe API, or using a `SQL where` clause:
```rust
let table = deltalake::open_table("./data/simple_table").await?;
let (table, delete_metrics) = DeltaOps(table)
.delete()
.with_predicate("num > 2")
.await?;
```
Here are the contents of the Delta table after the delete operation has been performed:

```
Expand Down

0 comments on commit af287f5

Please sign in to comment.