<?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: Understanding dropDuplicates in Delta Live Tables (DLT) with Photon in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/understanding-dropduplicates-in-delta-live-tables-dlt-with/m-p/122403#M46761</link>
    <description>&lt;P data-start="0" data-end="365"&gt;&lt;CODE data-start="0" data-end="9"&gt;FIRST()&lt;/CODE&gt; never stitches together values from different rows.&lt;BR data-start="61" data-end="64" data-is-only-node="" /&gt;When Photon executes &lt;CODE data-start="85" data-end="101"&gt;dropDuplicates&lt;/CODE&gt;, it deterministically chooses &lt;STRONG data-start="132" data-end="152"&gt;one complete row&lt;/STRONG&gt; for each set of duplicate keys and returns every column from that same row. If you ever encounter a result where columns appear to come from different rows, please open a support ticket—that would indicate a bug.&lt;/P&gt;
&lt;P data-start="367" data-end="527" data-is-last-node="" data-is-only-node=""&gt;Under the hood, &lt;CODE data-start="383" data-end="392"&gt;FIRST()&lt;/CODE&gt; just returns the first row encountered in each (deterministically-ordered) batch, so all column values originate from that single row.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jun 2025 21:52:26 GMT</pubDate>
    <dc:creator>cgrant</dc:creator>
    <dc:date>2025-06-20T21:52:26Z</dc:date>
    <item>
      <title>Understanding dropDuplicates in Delta Live Tables (DLT) with Photon</title>
      <link>https://community.databricks.com/t5/data-engineering/understanding-dropduplicates-in-delta-live-tables-dlt-with/m-p/121310#M46417</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I've been working with Delta Live Tables (DLT) in Databricks, and I'm particularly interested in understanding how the&amp;nbsp;dropDuplicates&amp;nbsp;function works when using the Photon engine. Photon is known for its columnar data processing capabilities, which significantly enhance performance. However, I've noticed something intriguing about how&amp;nbsp;dropDuplicates&amp;nbsp;handles data. It appears that the function might use the&amp;nbsp;FIRST&amp;nbsp;operation to determine which values to keep when removing duplicates.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plan.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17420iD757B598DE803BBA/image-size/large?v=v2&amp;amp;px=999" role="button" title="plan.png" alt="plan.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This raises an important question: Could&amp;nbsp;FIRST&amp;nbsp;potentially select values from different rows for different columns?&lt;/P&gt;&lt;P&gt;To illustrate, consider the following example:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;ID&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;COL1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;COL2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;A&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;A&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="30px"&gt;1&lt;/TD&gt;&lt;TD height="30px"&gt;B&lt;/TD&gt;&lt;TD height="30px"&gt;Z&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If we apply&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;dropDuplicates&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;on&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;ID&lt;/SPAN&gt;, the result might be (?)&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;ID&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;COL1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;COL2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;A&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;A&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="30px"&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;In this case, the value of&lt;SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;COL1 is A and&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;COL2&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;X&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ID=1&lt;/SPAN&gt;, but there's no guarantee that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;COL2&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;comes from the same row as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;COL1&lt;/SPAN&gt;. This behavior is due to the possibility that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;FIRST(COL1)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;FIRST(COL2)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;might select values from different rows (like 1 A Z which does not exist as record)&lt;/P&gt;&lt;P&gt;So, my question for the community is: &lt;STRONG&gt;When using&amp;nbsp;&lt;EM&gt;&lt;SPAN class=""&gt;dropDuplicates&lt;/SPAN&gt;&amp;nbsp;&lt;/EM&gt;in a DLT pipeline with Photon, how exactly are the values for the columns selected?&lt;U&gt; Is it possible that&amp;nbsp;&lt;SPAN class=""&gt;FIRST&lt;/SPAN&gt;&amp;nbsp;could take values from different rows&lt;/U&gt;?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Looking forward to your insights and experiences!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 09:14:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/understanding-dropduplicates-in-delta-live-tables-dlt-with/m-p/121310#M46417</guid>
      <dc:creator>lucami</dc:creator>
      <dc:date>2025-06-10T09:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding dropDuplicates in Delta Live Tables (DLT) with Photon</title>
      <link>https://community.databricks.com/t5/data-engineering/understanding-dropduplicates-in-delta-live-tables-dlt-with/m-p/122403#M46761</link>
      <description>&lt;P data-start="0" data-end="365"&gt;&lt;CODE data-start="0" data-end="9"&gt;FIRST()&lt;/CODE&gt; never stitches together values from different rows.&lt;BR data-start="61" data-end="64" data-is-only-node="" /&gt;When Photon executes &lt;CODE data-start="85" data-end="101"&gt;dropDuplicates&lt;/CODE&gt;, it deterministically chooses &lt;STRONG data-start="132" data-end="152"&gt;one complete row&lt;/STRONG&gt; for each set of duplicate keys and returns every column from that same row. If you ever encounter a result where columns appear to come from different rows, please open a support ticket—that would indicate a bug.&lt;/P&gt;
&lt;P data-start="367" data-end="527" data-is-last-node="" data-is-only-node=""&gt;Under the hood, &lt;CODE data-start="383" data-end="392"&gt;FIRST()&lt;/CODE&gt; just returns the first row encountered in each (deterministically-ordered) batch, so all column values originate from that single row.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jun 2025 21:52:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/understanding-dropduplicates-in-delta-live-tables-dlt-with/m-p/122403#M46761</guid>
      <dc:creator>cgrant</dc:creator>
      <dc:date>2025-06-20T21:52:26Z</dc:date>
    </item>
  </channel>
</rss>

