Skip to content

Commit

Permalink
feat: implement update operation (#1390)
Browse files Browse the repository at this point in the history
# Description
Users can now update data that matches a predicate. 

This operation should be encouraged over the replace write operation
since update determines which values require rewriting based on the
supplied predicate.

# Related Issue(s)
- closes #1126

---------

Co-authored-by: Will Jones <willjones127@gmail.com>
Co-authored-by: Robert Pack <42610831+roeap@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent 8294c5f commit 9730d59
Show file tree
Hide file tree
Showing 5 changed files with 1,429 additions and 401 deletions.
10 changes: 9 additions & 1 deletion rust/src/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ pub enum DeltaOperation {
/// The condition the to be deleted data must match
predicate: Option<String>,
},
/// Update data matching predicate from delta table
Update {
/// The update predicate
predicate: Option<String>,
},

/// Represents a Delta `StreamingUpdate` operation.
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -632,6 +637,7 @@ impl DeltaOperation {
DeltaOperation::Create { .. } => "CREATE TABLE",
DeltaOperation::Write { .. } => "WRITE",
DeltaOperation::Delete { .. } => "DELETE",
DeltaOperation::Update { .. } => "UPDATE",
DeltaOperation::StreamingUpdate { .. } => "STREAMING UPDATE",
DeltaOperation::Optimize { .. } => "OPTIMIZE",
DeltaOperation::FileSystemCheck { .. } => "FSCK",
Expand Down Expand Up @@ -675,7 +681,8 @@ impl DeltaOperation {
| Self::FileSystemCheck {}
| Self::StreamingUpdate { .. }
| Self::Write { .. }
| Self::Delete { .. } => true,
| Self::Delete { .. }
| Self::Update { .. } => true,
}
}

Expand All @@ -695,6 +702,7 @@ impl DeltaOperation {
// TODO add more operations
Self::Write { predicate, .. } => predicate.clone(),
Self::Delete { predicate, .. } => predicate.clone(),
Self::Update { predicate, .. } => predicate.clone(),
_ => None,
}
}
Expand Down
Loading

0 comments on commit 9730d59

Please sign in to comment.