DeltaMergeBuilder

DeltaMergeBuilder is a builder interface to specify how to merge data from a source DataFrame into the target delta table.

DeltaMergeBuilder is supposed to be created exclusively using DeltaTable.merge operator.

Table 1. DeltaMergeBuilder API / Operators
Name Description

whenMatched

whenMatched(): DeltaMergeMatchedActionBuilder
whenMatched(
  condition: Column): DeltaMergeMatchedActionBuilder
whenMatched(
  condition: String): DeltaMergeMatchedActionBuilder

whenNotMatched

whenNotMatched(): DeltaMergeNotMatchedActionBuilder
whenNotMatched(
  condition: Column): DeltaMergeNotMatchedActionBuilder
whenNotMatched(
  condition: String): DeltaMergeNotMatchedActionBuilder

Creating DeltaMergeBuilder Instance

DeltaMergeBuilder takes the following to be created:

  • Target DeltaTable

  • Source Data (DataFrame)

  • Condition (Column)

  • When Clauses (Seq[MergeIntoClause])

Executing Merge Operation — execute Method

execute(): Unit

execute resolves column references (and creates a MergeInto).

In the end, execute creates a PreprocessTableMerge to create a MergeIntoCommand that is executed right away.