<?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 how to implement delta load when table only has primary columns in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79179#M7769</link>
    <description>&lt;P&gt;I have a table where there are two columns and both are primary key, I want to do delta load when taking data from source to target. Any idea how to implement this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2024 06:32:51 GMT</pubDate>
    <dc:creator>Puneet096</dc:creator>
    <dc:date>2024-07-18T06:32:51Z</dc:date>
    <item>
      <title>how to implement delta load when table only has primary columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79179#M7769</link>
      <description>&lt;P&gt;I have a table where there are two columns and both are primary key, I want to do delta load when taking data from source to target. Any idea how to implement this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 06:32:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79179#M7769</guid>
      <dc:creator>Puneet096</dc:creator>
      <dc:date>2024-07-18T06:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to implement delta load when table only has primary columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79180#M7770</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/108699"&gt;@Puneet096&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;One approach you can use is merge into statement. Probably you can delete update part from below merge template, because it's unlikely that there will be update of values in composite primary key&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;MERGE INTO target_table AS target
USING source_table AS source
ON target.pk1 = source.pk1 AND target.pk2 = source.pk2
WHEN MATCHED AND source.last_updated &amp;gt; target.last_updated THEN
  UPDATE SET
    target.data = source.data,
    target.last_updated = source.last_updated
WHEN NOT MATCHED THEN
  INSERT (pk1, pk2, data, last_updated)
  VALUES (source.pk1, source.pk2, source.data, source.last_updated);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 06:42:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79180#M7770</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-07-18T06:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to implement delta load when table only has primary columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79185#M7771</link>
      <description>&lt;P&gt;Thanks for the response&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;, but the table has only two columns and both are primary key&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 07:16:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79185#M7771</guid>
      <dc:creator>Puneet096</dc:creator>
      <dc:date>2024-07-18T07:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to implement delta load when table only has primary columns</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79191#M7772</link>
      <description>&lt;P&gt;But that shouldn't be a problem. In merge condition you check both keys as in example above. If combination of two keysb already exists in the table then do nothing. If there is new combination of key1 and key2 just insert it into target table.&lt;/P&gt;&lt;P&gt;It's that simple, or maybe I don't fully understand your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 07:39:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-implement-delta-load-when-table-only-has-primary-columns/m-p/79191#M7772</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-07-18T07:39:16Z</dc:date>
    </item>
  </channel>
</rss>

