Builder for MERGE INTO table commands.
Constructed via SparkEx.DataFrame.merge_into/2, configured with match
actions, and executed with merge/1.
Examples
import SparkEx.Functions, only: [col: 1]
df
|> DataFrame.merge_into("target_table")
|> MergeIntoWriter.on(col("source.id") |> Column.eq(col("target.id")))
|> MergeIntoWriter.when_matched_update_all()
|> MergeIntoWriter.when_not_matched_insert_all()
|> MergeIntoWriter.merge()
Summary
Functions
Executes the MERGE INTO command.
Sets the merge condition (ON clause).
Deletes matched rows. Optional condition filters which matched rows to delete.
Updates specific columns of matched rows.
Updates all columns of matched rows.
Deletes target rows not matched by source.
Updates specific columns of target rows not matched by source.
Updates all columns of target rows not matched by source.
Inserts specific columns for non-matched source rows.
Inserts all columns for non-matched source rows.
Enables schema evolution for the merge operation.
Types
@type action() :: {:delete | :insert | :insert_star | :update | :update_star, SparkEx.Column.expr() | nil, [{SparkEx.Column.expr(), SparkEx.Column.expr()}]}
@type t() :: %SparkEx.MergeIntoWriter{ condition: SparkEx.Column.expr() | nil, match_actions: [action()], not_matched_actions: [action()], not_matched_by_source_actions: [action()], schema_evolution: boolean(), source_df: SparkEx.DataFrame.t(), target_table: String.t() }
Functions
Executes the MERGE INTO command.
Returns :ok or {:error, reason}.
@spec on(t(), SparkEx.Column.t()) :: t()
Sets the merge condition (ON clause).
@spec when_matched_delete(t(), SparkEx.Column.t() | nil) :: t()
Deletes matched rows. Optional condition filters which matched rows to delete.
@spec when_matched_update( t(), %{required(String.t()) => SparkEx.Column.t()}, SparkEx.Column.t() | nil ) :: t()
Updates specific columns of matched rows.
assignments is a map of %{"target_col" => Column.t()}.
@spec when_matched_update_all(t(), SparkEx.Column.t() | nil) :: t()
Updates all columns of matched rows.
@spec when_not_matched_by_source_delete(t(), SparkEx.Column.t() | nil) :: t()
Deletes target rows not matched by source.
@spec when_not_matched_by_source_update( t(), %{required(String.t()) => SparkEx.Column.t()}, SparkEx.Column.t() | nil ) :: t()
Updates specific columns of target rows not matched by source.
assignments is a map of %{"target_col" => Column.t()}.
@spec when_not_matched_by_source_update_all(t(), SparkEx.Column.t() | nil) :: t()
Updates all columns of target rows not matched by source.
@spec when_not_matched_insert( t(), %{required(String.t()) => SparkEx.Column.t()}, SparkEx.Column.t() | nil ) :: t()
Inserts specific columns for non-matched source rows.
assignments is a map of %{"target_col" => Column.t()}.
@spec when_not_matched_insert_all(t(), SparkEx.Column.t() | nil) :: t()
Inserts all columns for non-matched source rows.
Enables schema evolution for the merge operation.