You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Xianyin Xin (Jira)" <ji...@apache.org> on 2020/06/19 07:06:00 UTC

[jira] [Updated] (SPARK-32030) Support unlimited MATCHED and NOT MATCHED clauses in MERGE INTO

     [ https://issues.apache.org/jira/browse/SPARK-32030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xianyin Xin updated SPARK-32030:
--------------------------------
    Description: 
Now the {{MERGE INTO}} syntax is,
{code:sql}
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> ]{code}
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
{code:sql}
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 [, ...]]
{code}

 where {{when_clause}} is 
{code:java}
WHEN MATCHED [ AND <condition> ] THEN <matched_action>{code}
or
{code:java}
WHEN NOT MATCHED [ AND <condition> ] THEN <not_matched_action>{code}
 

  was:
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>
```



> Support unlimited MATCHED and NOT MATCHED clauses in MERGE INTO
> ---------------------------------------------------------------
>
>                 Key: SPARK-32030
>                 URL: https://issues.apache.org/jira/browse/SPARK-32030
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.0.1
>            Reporter: Xianyin Xin
>            Priority: Major
>
> Now the {{MERGE INTO}} syntax is,
> {code:sql}
> 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> ]{code}
> 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
> {code:sql}
> 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 [, ...]]
> {code}
>  where {{when_clause}} is 
> {code:java}
> WHEN MATCHED [ AND <condition> ] THEN <matched_action>{code}
> or
> {code:java}
> WHEN NOT MATCHED [ AND <condition> ] THEN <not_matched_action>{code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org