xianyinxin opened a new pull request #28875:
URL: https://github.com/apache/spark/pull/28875


   ### What changes were proposed in this pull request?
   This PR add unlimited MATCHED and NOT MATCHED clauses in MERGE INTO 
statement.
   
   ### Why are the changes needed?
   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>
    ```
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. The SQL command changes, but it is backward compatible.
   
   ### How was this patch tested?
   New tests added.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to