<?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: Nested subquery is not supported in the DELETE condition in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70758#M1348</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79106"&gt;@daniel_sahal&lt;/a&gt;&amp;nbsp;currently is a temp view&lt;/P&gt;</description>
    <pubDate>Mon, 27 May 2024 15:03:43 GMT</pubDate>
    <dc:creator>diego_poggioli</dc:creator>
    <dc:date>2024-05-27T15:03:43Z</dc:date>
    <item>
      <title>Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70712#M1346</link>
      <description>&lt;P&gt;According to the &lt;A href="https://docs.databricks.com/en/sql/language-manual/delta-delete-from.html" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; the&amp;nbsp;&lt;SPAN class=""&gt;WHERE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;predicate in a &lt;STRONG&gt;DELETE&lt;/STRONG&gt; statement should supports subqueries, including&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;IN&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;NOT&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;IN&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;EXISTS&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;NOT&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;EXISTS&lt;/SPAN&gt;&lt;SPAN&gt;, and scalar subqueries.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if I try to run a query like:&lt;/P&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;&lt;LI-CODE lang="php"&gt;DELETE FROM dev.gold.table AS trg
WHERE EXISTS (
    select distinct year_month, version
    from source
    where trg.year_month = year_month
    and trg.version = version
)&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;&lt;P&gt;&amp;nbsp;I get the error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;A class="" href="https://docs.databricks.com/error-messages/error-classes.html#delta_nested_subquery_not_supported" target="_blank" rel="noopener noreferrer"&gt;DELTA_NESTED_SUBQUERY_NOT_SUPPORTED&lt;/A&gt;&lt;SPAN&gt;] Nested subquery is not supported in the DELETE condition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Same error if I use &lt;STRONG&gt;IN&lt;/STRONG&gt; after grouping the year_month and version into a single column:&lt;/SPAN&gt;&lt;/P&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;&lt;LI-CODE lang="markup"&gt;DELETE FROM dev.gold.table AS trg
   WHERE year_month_version IN (select * FROM v_distinct_year_month_version)&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;&lt;P&gt;&lt;SPAN&gt;Any solution, other than a merge delete, to solve the problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm running a SQL notebook with serverless warehouse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 12:00:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70712#M1346</guid>
      <dc:creator>diego_poggioli</dc:creator>
      <dc:date>2024-05-27T12:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70745#M1347</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/87287"&gt;@diego_poggioli&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;What is the "source" in your WHERE statement? Is it a table or a view/temp view?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 13:54:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70745#M1347</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2024-05-27T13:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70758#M1348</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79106"&gt;@daniel_sahal&lt;/a&gt;&amp;nbsp;currently is a temp view&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 15:03:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70758#M1348</guid>
      <dc:creator>diego_poggioli</dc:creator>
      <dc:date>2024-05-27T15:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70780#M1349</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/87287"&gt;@diego_poggioli&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you try selecting a 'year_month_version' column from the view instead of select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DELETE FROM dev.gold.table AS trg
   WHERE year_month_version IN (select year_month_version FROM v_distinct_year_month_version)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 17:47:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70780#M1349</guid>
      <dc:creator>Tejas2022</dc:creator>
      <dc:date>2024-05-27T17:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70846#M1353</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/87287"&gt;@diego_poggioli&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This could be it. Try materializing the view first and see if it fixes the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 05:48:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70846#M1353</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2024-05-28T05:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Nested subquery is not supported in the DELETE condition</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70850#M1354</link>
      <description>&lt;P&gt;Yes, correct! using a table instead of a view fixed the error&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 07:04:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/nested-subquery-is-not-supported-in-the-delete-condition/m-p/70850#M1354</guid>
      <dc:creator>diego_poggioli</dc:creator>
      <dc:date>2024-05-28T07:04:43Z</dc:date>
    </item>
  </channel>
</rss>

