Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-32030

Support unlimited MATCHED and NOT MATCHED clauses in MERGE INTO

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.1.0
    • SQL
    • None

    Description

      Now the MERGE INTO syntax is,

      MERGE INTO [db_name.]target_table [AS target_alias]
       USING [db_name.]source_table [<time_travel_version>] [AS source_alias]
       ON <merge_condition>
       [ WHEN MATCHED [ AND <condition> ] THEN <matched_action> ]
       [ WHEN MATCHED [ AND <condition> ] THEN <matched_action> ]
       [ WHEN NOT MATCHED [ AND <condition> ] THEN <not_matched_action> ]

      It would be nice if we support unlimited MATCHED and NOT MATCHED clauses in MERGE INTO statement, because users may want to deal with different "AND <condition>"s, the result of which just like a series of "CASE WHEN"s. The expected syntax looks like

      MERGE INTO [db_name.]target_table [AS target_alias]
       USING [db_name.]source_table [<time_travel_version>] [AS source_alias]
       ON <merge_condition>
       [when_clause [, ...]]
      

      where when_clause is

      WHEN MATCHED [ AND <condition> ] THEN <matched_action>

      or

      WHEN NOT MATCHED [ AND <condition> ] THEN <not_matched_action>

       

      Attachments

        Activity

          People

            xinxianyin Xianyin Xin
            xinxianyin Xianyin Xin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: