<?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: Issue with Combination of INSERT + CTE (with clause) + Dynamic query (IDENTIFIER function) in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91943#M38300</link>
    <description>&lt;P&gt;Please mark this as resolved.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2024 17:20:27 GMT</pubDate>
    <dc:creator>UdayRPai</dc:creator>
    <dc:date>2024-09-26T17:20:27Z</dc:date>
    <item>
      <title>Issue with Combination of INSERT + CTE (with clause) + Dynamic query (IDENTIFIER function)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91893#M38293</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We are trying to insert into a table using a CTE (WITH clause query).&lt;BR /&gt;In the insert we are using the INDENTIFIER function as the catalog name is retrieved dynamically.&lt;BR /&gt;This is causing the insert to fail with an error - T&lt;SPAN&gt;he table or view `cte_query` cannot be found.&lt;BR /&gt;Any idea how this cam be fixed?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CREATE&lt;/SPAN&gt; &lt;SPAN&gt;TABLE&lt;/SPAN&gt;&amp;nbsp;catalog_name&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;schema_name&lt;/SPAN&gt;&lt;SPAN&gt;.target_table1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col1 &lt;/SPAN&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col2 &lt;/SPAN&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DECLARE VARIABLE var_catalog_name STRING;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;SET&lt;/SPAN&gt;&lt;SPAN&gt; var_catalog_name &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; catalog_name &lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;system&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;information_schema&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;catalogs&lt;/SPAN&gt; &lt;SPAN&gt;where&lt;/SPAN&gt;&lt;SPAN&gt; catalog_name &lt;/SPAN&gt;&lt;SPAN&gt;like&lt;/SPAN&gt; &lt;SPAN&gt;'my_catalog%'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;INSERT&lt;/SPAN&gt; &lt;SPAN&gt;INTO&lt;/SPAN&gt;&lt;SPAN&gt; IDENTIFIER(var_catalog_name &lt;/SPAN&gt;&lt;SPAN&gt;||&lt;/SPAN&gt; &lt;SPAN&gt;'.schema_name.target_table1'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;col1,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;col2&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;) &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;WITH&lt;/SPAN&gt;&lt;SPAN&gt; cte_query &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; 'A' as col1, &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current_date() as col2&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; &amp;nbsp;col1,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col2&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp;cte_query&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 14:30:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91893#M38293</guid>
      <dc:creator>UdayRPai</dc:creator>
      <dc:date>2024-09-26T14:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Combination of INSERT + CTE (with clause) + Dynamic query (IDENTIFIER function)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91943#M38300</link>
      <description>&lt;P&gt;Please mark this as resolved.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 17:20:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91943#M38300</guid>
      <dc:creator>UdayRPai</dc:creator>
      <dc:date>2024-09-26T17:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Combination of INSERT + CTE (with clause) + Dynamic query (IDENTIFIER function)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91947#M38301</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/123091"&gt;@UdayRPai&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Could you share solution of you find one? This way you can help community &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 17:39:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/91947#M38301</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-09-26T17:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Combination of INSERT + CTE (with clause) + Dynamic query (IDENTIFIER function)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/92668#M38498</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We used the USE CATALOG statement with EXECUTE IMMEDIATE at the beginning and removed the catalog name from individual insert statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 15:22:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-combination-of-insert-cte-with-clause-dynamic-query/m-p/92668#M38498</guid>
      <dc:creator>UdayRPai</dc:creator>
      <dc:date>2024-10-03T15:22:04Z</dc:date>
    </item>
  </channel>
</rss>

