<?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 Window functions in Change Data Feed in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/window-functions-in-change-data-feed/m-p/48426#M28304</link>
    <description>&lt;DIV&gt;&lt;SPAN&gt;Hello!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;I am currently exploring the possibility of implementing incremental changes in our company's ETL pipeline and looking into Change Data Feed option. There are a couple of challenges I'm uncertain about.&lt;/P&gt;&lt;P&gt;For instance, we have a piece of logic like this:&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;lag(is_available, 1, date '1970-01-01') over (partition by store, product_id order by is_available) as was_available_yesterday&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Another case involves calculating the most popular quantity sold:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;first_value(quantity) over (partition by sales_date, store, product order by count(*) desc) as quantity_mode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In both cases, I need to reference historical data. What would be the best approach to handle such scenarios? Should I create a separate table to store values for each unique combination of store and product, or should I join with a history table? I'm concerned about performance in the second case, as scanning the entire history table could be costly, especially considering that I have several fields that rely on historical context.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2023 17:01:11 GMT</pubDate>
    <dc:creator>mike_engineer</dc:creator>
    <dc:date>2023-10-05T17:01:11Z</dc:date>
    <item>
      <title>Window functions in Change Data Feed</title>
      <link>https://community.databricks.com/t5/data-engineering/window-functions-in-change-data-feed/m-p/48426#M28304</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Hello!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;I am currently exploring the possibility of implementing incremental changes in our company's ETL pipeline and looking into Change Data Feed option. There are a couple of challenges I'm uncertain about.&lt;/P&gt;&lt;P&gt;For instance, we have a piece of logic like this:&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;lag(is_available, 1, date '1970-01-01') over (partition by store, product_id order by is_available) as was_available_yesterday&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Another case involves calculating the most popular quantity sold:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;first_value(quantity) over (partition by sales_date, store, product order by count(*) desc) as quantity_mode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In both cases, I need to reference historical data. What would be the best approach to handle such scenarios? Should I create a separate table to store values for each unique combination of store and product, or should I join with a history table? I'm concerned about performance in the second case, as scanning the entire history table could be costly, especially considering that I have several fields that rely on historical context.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 17:01:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/window-functions-in-change-data-feed/m-p/48426#M28304</guid>
      <dc:creator>mike_engineer</dc:creator>
      <dc:date>2023-10-05T17:01:11Z</dc:date>
    </item>
  </channel>
</rss>

