pypika icon indicating copy to clipboard operation
pypika copied to clipboard

Feature: Merge Statement

Open pykenny opened this issue 2 years ago • 0 comments

Support on MERGE statement, an enhanced upsert operation allowing conditioned record deletion on destination table.

Often designed with syntax like below:

MERGE [INTO] <destination>
USING <source>
ON <merge_condition>
WHEN MATCHED [AND <extra_conditions>]
  THEN {<update_clause> | <delete_clause>}
WHEN NOT MATCHED [BY TARGET] [AND <extra_conditions>]
  THEN <insert_clause>
WHEN NOT MATCHED BY SOURCE [AND <extra_conditions>]
  THEN {<update_clause> | <delete_clause>}
...

Examples:

pykenny avatar Sep 08 '22 02:09 pykenny