You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2022/10/26 15:56:00 UTC

[jira] [Commented] (SPARK-40921) Add WHEN NOT MATCHED BY SOURCE clause to MERGE INTO command

    [ https://issues.apache.org/jira/browse/SPARK-40921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624557#comment-17624557 ] 

Apache Spark commented on SPARK-40921:
--------------------------------------

User 'johanl-db' has created a pull request for this issue:
https://github.com/apache/spark/pull/38400

> Add WHEN NOT MATCHED BY SOURCE clause to MERGE INTO command
> -----------------------------------------------------------
>
>                 Key: SPARK-40921
>                 URL: https://issues.apache.org/jira/browse/SPARK-40921
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.4.0
>            Reporter: Johan Lasperas
>            Priority: Major
>
> The MERGE INTO syntax in Spark allows two types of WHEN clause:
>  * WHEN MATCHED: Specify optional condition and actions (delete or update) to apply to rows that satisfy the merge condition.
>  * WHEN NOT MATCHED: Specify optional condition and actions (insert) to apply toi rows from the source table that don't satisfy the match condition.
> Other products also offer a third type of WHEN clause:
>  * WHEN NOT MATCHED BY SOURCE: Specify optional condition and actions (delete or update) to apply to rows from the target table that don't satisfy the merge condition.
> See for example [T-SQL Merge Documentation|https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-ver16]
> Example:
> {code:java}
> MERGE INTO target
> USING source
> ON target.key = source.key
> WHEN MATCHED THEN UPDATE SET *
> WHEN NOT MATCHED THEN INSERT *
> WHEN NOT MATCHED BY SOURCE THEN DELETE {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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