<?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: Select from a dynamic table name returned by databricks function in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65106#M32737</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;. This does not work in Databricks notebook, error attached. This looks like a SQL Server solution.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Mar 2024 16:08:41 GMT</pubDate>
    <dc:creator>sgupta</dc:creator>
    <dc:date>2024-03-30T16:08:41Z</dc:date>
    <item>
      <title>Select from a dynamic table name returned by databricks function</title>
      <link>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65010#M32725</link>
      <description>&lt;UL&gt;&lt;LI&gt;I have a databricks function that returns a table_name&lt;/LI&gt;&lt;/UL&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CREATE OR REPLACE&lt;/SPAN&gt; &lt;SPAN&gt;FUNCTION&lt;/SPAN&gt; &lt;SPAN&gt;test_func&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;RETURNS&lt;/SPAN&gt;&lt;SPAN&gt; string&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; READS &lt;/SPAN&gt;&lt;SPAN&gt;SQL&lt;/SPAN&gt; &lt;SPAN&gt;DATA&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; 'table_name'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;UL&gt;&lt;LI&gt;I want to select from the table that is returned by this function. How can I make it work in SQL, something like this -&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM (SELECT&amp;nbsp;&lt;SPAN&gt;test_func())&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Currently this SELECT is returning a single row with the table name and not the contents of the table name.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 29 Mar 2024 14:37:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65010#M32725</guid>
      <dc:creator>sgupta</dc:creator>
      <dc:date>2024-03-29T14:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select from a dynamic table name returned by databricks function</title>
      <link>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65106#M32737</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;. This does not work in Databricks notebook, error attached. This looks like a SQL Server solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2024 16:08:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65106#M32737</guid>
      <dc:creator>sgupta</dc:creator>
      <dc:date>2024-03-30T16:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select from a dynamic table name returned by databricks function</title>
      <link>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65107#M32738</link>
      <description>&lt;P&gt;I looked at this post&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/77475436/in-databricks-workbook-using-spark-sql-how-to-pass-parameters-thru-sql-udf-func" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/77475436/in-databricks-workbook-using-spark-sql-how-to-pass-parameters-thru-sql-udf-func&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;What I want is to replace the static table name with the table name passed as parameter (param_table_name). Is it possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REPLACE FUNCTION mydb.tbl_filter(a_val INT, param_table_name string)
RETURNS TABLE(a INT, b INT)
RETURN SELECT * FROM tbl_filter.param_table_name tf 
WHERE tf.a = tbl_filter.a_val;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2024 16:51:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/select-from-a-dynamic-table-name-returned-by-databricks-function/m-p/65107#M32738</guid>
      <dc:creator>sgupta</dc:creator>
      <dc:date>2024-03-30T16:51:50Z</dc:date>
    </item>
  </channel>
</rss>

