<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic What is the behavior when merge key is not unique in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/what-is-the-behavior-when-merge-key-is-not-unique/m-p/65556#M32840</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the MERGE statement, if merge key is not unique on both source and target, it will throw error. If merge key is unique in source but not unique in target, WHEN MATCHED THEN DELETE/UPDATE should work or not? For example merge key is id. Src has 1 row id = 1, target has multiple rows with id = 1. WHEN MATCHED will update or delete all rows in target for id = 1 or pick up 1 randomly?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;</description>
    <pubDate>Fri, 05 Apr 2024 07:02:36 GMT</pubDate>
    <dc:creator>MikeGo</dc:creator>
    <dc:date>2024-04-05T07:02:36Z</dc:date>
    <item>
      <title>What is the behavior when merge key is not unique</title>
      <link>https://community.databricks.com/t5/data-engineering/what-is-the-behavior-when-merge-key-is-not-unique/m-p/65556#M32840</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the MERGE statement, if merge key is not unique on both source and target, it will throw error. If merge key is unique in source but not unique in target, WHEN MATCHED THEN DELETE/UPDATE should work or not? For example merge key is id. Src has 1 row id = 1, target has multiple rows with id = 1. WHEN MATCHED will update or delete all rows in target for id = 1 or pick up 1 randomly?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 07:02:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-is-the-behavior-when-merge-key-is-not-unique/m-p/65556#M32840</guid>
      <dc:creator>MikeGo</dc:creator>
      <dc:date>2024-04-05T07:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: What is the behavior when merge key is not unique</title>
      <link>https://community.databricks.com/t5/data-engineering/what-is-the-behavior-when-merge-key-is-not-unique/m-p/65680#M32892</link>
      <description>&lt;P&gt;Cool, this is what I tested out. Great to get confirmed. Thanks. BTW,&amp;nbsp;&lt;A class="" href="https://medium.com/@ritik20023/delta-lake-upserting-without-primary-key-f4a931576b0" target="_blank" rel="noopener noreferrer"&gt;https://medium.com/@ritik20023/delta-lake-upserting-without-primary-key-f4a931576b0&lt;/A&gt;&amp;nbsp;has a workaround which can fix the merge with duplicate merge key on both source and target.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 22:27:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-is-the-behavior-when-merge-key-is-not-unique/m-p/65680#M32892</guid>
      <dc:creator>MikeGo</dc:creator>
      <dc:date>2024-04-05T22:27:34Z</dc:date>
    </item>
  </channel>
</rss>

