deltalake_core::operations

Module merge

Source
Expand description

Merge data from a source dataset with the target Delta Table based on a join predicate. A full outer join is performed which results in source and target records that match, source records that do not match, or target records that do not match.

Users can specify update, delete, and insert operations for these categories and specify additional predicates for finer control. The order of operations specified matter. See MergeBuilder for more information

§Example

let table = open_table("../path/to/table")?;
let (table, metrics) = DeltaOps(table)
    .merge(source, col("target.id").eq(col("source.id")))
    .with_source_alias("source")
    .with_target_alias("target")
    .when_matched_update(|update| {
        update
            .update("value", col("source.value") + lit(1))
            .update("modified", col("source.modified"))
    })?
    .when_not_matched_insert(|insert| {
        insert
            .set("id", col("source.id"))
            .set("value", col("source.value"))
            .set("modified", col("source.modified"))
    })?
    .await?

Structs§