<?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 Re: Does MERGE statement preserve order? (Slowly Changing Dimensions) in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12443#M7243</link>
    <description>&lt;P&gt;you could guarantee order by actually ordering the dataframe which you want to merge or use a window function (and keeping only the most recent record f.e.).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The upsert is an expensive operation, so depending on the amount of data which has to be evaluated it can take a while indeed. &lt;/P&gt;&lt;P&gt;There are some tweaks possible though:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/databricks/kb/delta/delta-merge-into" target="test_blank"&gt;https://docs.microsoft.com/en-us/azure/databricks/kb/delta/delta-merge-into&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2022 11:06:39 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2022-07-27T11:06:39Z</dc:date>
    <item>
      <title>Does MERGE statement preserve order? (Slowly Changing Dimensions)</title>
      <link>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12442#M7242</link>
      <description>&lt;P&gt;In the case of processing multiple source files - with potentially, one or multiple entity versions per source - being able to use the MERGE statement whilst preserving the order is key to ensure the correct versioning of entity versions (aka, version 1 starts at X to Y, then comes version 2 from Y to Z, etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, as far as I can tell, there is no guarantee that the data will be processed (MERGED) according to the order in the DataFrame. Has anyone confirmed this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The current way to bypass this is to process each extraction date separately for the MERGE statement however, it is quite a slow process since Azure takes a long time to MERGE.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 14:01:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12442#M7242</guid>
      <dc:creator>TMNGB</dc:creator>
      <dc:date>2022-07-26T14:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Does MERGE statement preserve order? (Slowly Changing Dimensions)</title>
      <link>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12443#M7243</link>
      <description>&lt;P&gt;you could guarantee order by actually ordering the dataframe which you want to merge or use a window function (and keeping only the most recent record f.e.).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The upsert is an expensive operation, so depending on the amount of data which has to be evaluated it can take a while indeed. &lt;/P&gt;&lt;P&gt;There are some tweaks possible though:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/databricks/kb/delta/delta-merge-into" target="test_blank"&gt;https://docs.microsoft.com/en-us/azure/databricks/kb/delta/delta-merge-into&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 11:06:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12443#M7243</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-07-27T11:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Does MERGE statement preserve order? (Slowly Changing Dimensions)</title>
      <link>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12444#M7244</link>
      <description>&lt;P&gt;Hi @Guilherme Banhudo​&amp;nbsp;I hope that werners answer would have helped you. Please let me know if you still have doubts or queries.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 17:09:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/does-merge-statement-preserve-order-slowly-changing-dimensions/m-p/12444#M7244</guid>
      <dc:creator>Noopur_Nigam</dc:creator>
      <dc:date>2022-08-29T17:09:22Z</dc:date>
    </item>
  </channel>
</rss>

