<?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: Define SQL table name using Python in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/define-sql-table-name-using-python/m-p/82143#M36536</link>
    <description>&lt;P&gt;What is unclear to you? I need to create a table that depend on the username of the current user&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2024 09:09:40 GMT</pubDate>
    <dc:creator>alm</dc:creator>
    <dc:date>2024-08-07T09:09:40Z</dc:date>
    <item>
      <title>Define SQL table name using Python</title>
      <link>https://community.databricks.com/t5/data-engineering/define-sql-table-name-using-python/m-p/81416#M36299</link>
      <description>&lt;P&gt;I want to control which schema a notebook writes. I want it to depend on the user that runs the notebook.&lt;/P&gt;&lt;P&gt;For now, the scope is to suport languages Python and SQL. I have written a Python function, `get_path`, that returns the full path of the destination.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My idea was to create a SQL function that wraps the Python function.&lt;/P&gt;&lt;P&gt;```&lt;/P&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;GETPATH&lt;/SPAN&gt;&lt;SPAN&gt;(catalog_name &lt;/SPAN&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;SPAN&gt;, schema_name &lt;/SPAN&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;SPAN&gt;, table_name &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;returns&lt;/SPAN&gt; &lt;SPAN&gt;string&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;language&lt;/SPAN&gt;&lt;SPAN&gt; python&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; $$&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;path&lt;/SPAN&gt; &lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; get_path&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; get_path(catalog_name, schema_name, table_name) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&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;Surprisingly, or not so much so, this doesn't work.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any idea how to implement something like this? It might be, that it should handled completely different.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If I can set the catalog and schema of notebooks in a folder somewhere else so that the notebook only defines the table name, it would also solve the problem.&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 06:33:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/define-sql-table-name-using-python/m-p/81416#M36299</guid>
      <dc:creator>alm</dc:creator>
      <dc:date>2024-08-01T06:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Define SQL table name using Python</title>
      <link>https://community.databricks.com/t5/data-engineering/define-sql-table-name-using-python/m-p/82143#M36536</link>
      <description>&lt;P&gt;What is unclear to you? I need to create a table that depend on the username of the current user&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 09:09:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/define-sql-table-name-using-python/m-p/82143#M36536</guid>
      <dc:creator>alm</dc:creator>
      <dc:date>2024-08-07T09:09:40Z</dc:date>
    </item>
  </channel>
</rss>

