<?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: LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174885#M56938</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/233222"&gt;@RGSLCA&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The difference here is simply &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;where the date filter is applied&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, especially since&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ta.dtx&lt;/STRONG&gt;&lt;SPAN&gt; belongs to the left table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, the date condition is part of the &lt;STRONG&gt;LEFT JOIN&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;. It only controls whether a matching row from &lt;STRONG&gt;TableB&lt;FONT face="DM Mono, Consolas, monospace" color="#c7254e"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;is returned. Rows from &lt;STRONG&gt;TableA&lt;FONT face="DM Mono, Consolas, monospace" color="#c7254e"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;with other dates are still preserved, but with&amp;nbsp;tb.id = NULL.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, moving the date condition to &lt;STRONG&gt;WHERE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; actually filters &lt;STRONG&gt;TableA&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, giving you the intended result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried reproducing your scenario with sample data in &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Databricks Serverless SQL&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; Returned IDs 1, 2 and 4, including other dates with tb.id = NULL&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; Returned only ID 1, matching the requested date.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data_pulse_0-1793232393316.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32637iA2BB2207DD0C57C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="data_pulse_0-1793232393316.png" alt="data_pulse_0-1793232393316.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Interestingly, I also ran &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A in Microsoft SQL Server&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, and it returned exactly the same results. Same result with PostgreSQL too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data_pulse_2-1793232474181.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32639i0BD78E43F6149DDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="data_pulse_2-1793232474181.png" alt="data_pulse_2-1793232474181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The Databricks Photon execution plan confirmed this behaviour too, showing a LeftOuter&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;join with the date restriction as part of the join condition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So this looks like &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;standard SQL LEFT JOIN&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;SPAN&gt;behaviour rather than a recent Databricks change&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If your intention is to filter&amp;nbsp;&lt;STRONG&gt;TableA&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;by date while still preserving unmatched rows from &lt;STRONG&gt;TableB&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, I'd recommend &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, or filtering &lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;TableA&lt;/STRONG&gt; in a CTE before joining.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;References:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-join" target="_blank"&gt;&lt;SPAN&gt;Databricks JOIN documentation&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Thu, 29 Oct 2026 00:13:02 GMT</pubDate>
    <dc:creator>data_pulse</dc:creator>
    <dc:date>2026-10-29T00:13:02Z</dc:date>
    <item>
      <title>LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER</title>
      <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174881#M56937</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I may need to investigate further but this is my observation,&lt;/P&gt;&lt;P&gt;I had a SQL query working fine until today,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Query-A
SELECT ta.id,tb.id
FROM TableA ta
     left join
     TableB tb
     on ta.id = tb.id
     and ta.dtx = to_date(&amp;lt;date string&amp;gt;)
where
     ta.some_other_col = true

Query-B
SELECT ta.id,tb.id
FROM TableA ta
     left join
     TableB tb
     on ta.id = tb.id
where
     ta.dtx = to_date(&amp;lt;date string&amp;gt;)
     and
     ta.some_other_col = true&lt;/LI-CODE&gt;&lt;P&gt;Option-A Query started not filtering rows and sending different dates without considering the date filter&lt;/P&gt;&lt;P&gt;I had to modify the SQL to be like Option-B to make the filter working.&lt;/P&gt;&lt;P&gt;I have tested on Oracle and Other platforms this seems to work fine. Can someone tell me what am I doing wrong or is there a reason for this ? it looked like a sudden change but I cant believe that as a reason.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: The original query was a CTE with multiple steps like above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2026 23:17:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174881#M56937</guid>
      <dc:creator>RGSLCA</dc:creator>
      <dc:date>2026-10-28T23:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER</title>
      <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174885#M56938</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/233222"&gt;@RGSLCA&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The difference here is simply &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;where the date filter is applied&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, especially since&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ta.dtx&lt;/STRONG&gt;&lt;SPAN&gt; belongs to the left table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, the date condition is part of the &lt;STRONG&gt;LEFT JOIN&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;. It only controls whether a matching row from &lt;STRONG&gt;TableB&lt;FONT face="DM Mono, Consolas, monospace" color="#c7254e"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;is returned. Rows from &lt;STRONG&gt;TableA&lt;FONT face="DM Mono, Consolas, monospace" color="#c7254e"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;with other dates are still preserved, but with&amp;nbsp;tb.id = NULL.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, moving the date condition to &lt;STRONG&gt;WHERE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; actually filters &lt;STRONG&gt;TableA&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, giving you the intended result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried reproducing your scenario with sample data in &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Databricks Serverless SQL&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; Returned IDs 1, 2 and 4, including other dates with tb.id = NULL&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; Returned only ID 1, matching the requested date.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data_pulse_0-1793232393316.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32637iA2BB2207DD0C57C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="data_pulse_0-1793232393316.png" alt="data_pulse_0-1793232393316.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Interestingly, I also ran &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query A in Microsoft SQL Server&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, and it returned exactly the same results. Same result with PostgreSQL too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data_pulse_2-1793232474181.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32639i0BD78E43F6149DDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="data_pulse_2-1793232474181.png" alt="data_pulse_2-1793232474181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The Databricks Photon execution plan confirmed this behaviour too, showing a LeftOuter&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;join with the date restriction as part of the join condition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So this looks like &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;standard SQL LEFT JOIN&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;SPAN&gt;behaviour rather than a recent Databricks change&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If your intention is to filter&amp;nbsp;&lt;STRONG&gt;TableA&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;by date while still preserving unmatched rows from &lt;STRONG&gt;TableB&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, I'd recommend &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Query B&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, or filtering &lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;TableA&lt;/STRONG&gt; in a CTE before joining.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;References:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-join" target="_blank"&gt;&lt;SPAN&gt;Databricks JOIN documentation&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 29 Oct 2026 00:13:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174885#M56938</guid>
      <dc:creator>data_pulse</dc:creator>
      <dc:date>2026-10-29T00:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER</title>
      <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174887#M56940</link>
      <description>&lt;P&gt;Thanks! , let me revisit this! appreciate it!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2026 01:15:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/174887#M56940</guid>
      <dc:creator>RGSLCA</dc:creator>
      <dc:date>2026-10-29T01:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER</title>
      <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/175030#M56961</link>
      <description>&lt;P&gt;Absolutely, correct, there have been a filter for preventing NULLs flowing through.&lt;BR /&gt;Oracle also producing same,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RGSLCA_1-1793374126591.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32688i379E82E81E9EA9B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RGSLCA_1-1793374126591.png" alt="RGSLCA_1-1793374126591.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2026 15:29:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/175030#M56961</guid>
      <dc:creator>RGSLCA</dc:creator>
      <dc:date>2026-10-30T15:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN WITH FILTER vs LEFT JOIN and WHERE FILTER</title>
      <link>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/175032#M56962</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/233222"&gt;@RGSLCA&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nice that you observed this in oracle too.&amp;nbsp;&lt;SPAN&gt;Good to see the behaviour is consistent across platforms.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2026 15:40:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/left-join-with-filter-vs-left-join-and-where-filter/m-p/175032#M56962</guid>
      <dc:creator>data_pulse</dc:creator>
      <dc:date>2026-10-30T15:40:25Z</dc:date>
    </item>
  </channel>
</rss>

