<?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: Using yml variables as table owner through SQL in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115655#M45144</link>
    <description>&lt;P&gt;Yea, still no luck. I might start looking into refactoring the scripts into notebooks and be done with it.&lt;BR /&gt;&lt;BR /&gt;Using backslash in yml (&lt;SPAN&gt;admin_group&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;\`&lt;SPAN&gt;azure_admin_group_dev&lt;/SPAN&gt;\`&lt;/SPAN&gt;)&amp;nbsp; will return:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;'\\`azure_admin_group_dev\\`'&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Apr 2025 12:34:37 GMT</pubDate>
    <dc:creator>AsgerLarsen</dc:creator>
    <dc:date>2025-04-16T12:34:37Z</dc:date>
    <item>
      <title>Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115647#M45136</link>
      <description>&lt;P&gt;I'm trying to change the ownership of a table in the Unity Catalog created through a SQL script. I want to do this though code.&lt;/P&gt;&lt;P&gt;I'm using a standard databricks bundle setup, which uses three workspaces: &lt;STRONG&gt;dev&lt;/STRONG&gt;, &lt;STRONG&gt;test&lt;/STRONG&gt; and &lt;STRONG&gt;prod&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I have created a variable in the databricks.yml file, let's call it '&lt;STRONG&gt;admin_group&lt;/STRONG&gt;'.&lt;BR /&gt;&lt;BR /&gt;The variable's value depends on the workspace, so if the code is being executed from the dev environment, the value would be '&lt;STRONG&gt;azure_admin_group_dev&lt;/STRONG&gt;', if the environment is test, the value would be '&lt;STRONG&gt;azure_admin_group_test&lt;/STRONG&gt;' etc.&lt;/P&gt;&lt;P&gt;I'm trying to pass this variable into the ALTER TABLE with the OWNER TO statement, so the executed result would look like this:&lt;/P&gt;&lt;PRE&gt;ALTER TABLE&amp;nbsp;catalog_name.schema_name.table_name&amp;nbsp;OWNER TO&amp;nbsp;`azure_admin_group_dev`&lt;/PRE&gt;&lt;P&gt;Notice the backticks wrapped around the admin_group value.&lt;BR /&gt;&lt;BR /&gt;I run into some issue because of certain limitations:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The 'OWNER TO' SQL statement requires the value to be wrapped in backticks (``)&lt;/LI&gt;&lt;LI&gt;The 'OWNER TO' SQL statement can't execute subqueries like e.g. (&lt;SPAN&gt;SELECT&lt;/SPAN&gt; &lt;SPAN&gt;CONCAT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'`'&lt;/SPAN&gt;&lt;SPAN&gt;,{{admin_group}},&lt;/SPAN&gt;&lt;SPAN&gt;'`'&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; c)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The .yml files, where the variable value is defined, doesn't allow for backticks unless singlequotes are wrapped around them, in which case the statement won't accept the value.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I would very much like to be able to do this in an SQL file.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;With these limitations, is it even possible to achive this?&lt;BR /&gt;Any input is appriciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 10:43:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115647#M45136</guid>
      <dc:creator>AsgerLarsen</dc:creator>
      <dc:date>2025-04-16T10:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115648#M45137</link>
      <description>&lt;P&gt;have you tried without backticks?&amp;nbsp; I mean using common variable substitution:&lt;BR /&gt;ALTER TABLE my_table OWNER TO '${new_owner}' (new_owner is a dab var of course).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 11:10:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115648#M45137</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2025-04-16T11:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115649#M45138</link>
      <description>&lt;P&gt;I have tried that, it will result in single quotes being wrapped around the variable value and cause a syntax error&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 11:25:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115649#M45138</guid>
      <dc:creator>AsgerLarsen</dc:creator>
      <dc:date>2025-04-16T11:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115651#M45140</link>
      <description>&lt;P&gt;how does your variables section look like?&lt;BR /&gt;Perhaps something you have tried but what if you use backticks instead of the single quotes in the query.&lt;BR /&gt;The var is substituted with the value (the value itself does not contains backticks though!).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 11:41:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115651#M45140</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2025-04-16T11:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115652#M45141</link>
      <description>&lt;P&gt;The variable looks like this in the yml file:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;admin_group&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;azure_admin_group_dev&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This will return the value like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;'azure_admin_group_dev'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;If I add the backticks in as part of the value like this:&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;admin_group: '`azure_admin_group_dev`'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;The value will be returned like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;'`azure_admin_group_dev`'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Unfortunatly, none of these values are acceptable in the OWNER TO statement. It needs to be returned like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;`azure_admin_group_dev`&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 11:54:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115652#M45141</guid>
      <dc:creator>AsgerLarsen</dc:creator>
      <dc:date>2025-04-16T11:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115653#M45142</link>
      <description>&lt;P&gt;ugh,&lt;BR /&gt;SQL... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;tried to escape the backticks in the yml?&amp;nbsp; so \`group\`?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 12:15:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115653#M45142</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2025-04-16T12:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115655#M45144</link>
      <description>&lt;P&gt;Yea, still no luck. I might start looking into refactoring the scripts into notebooks and be done with it.&lt;BR /&gt;&lt;BR /&gt;Using backslash in yml (&lt;SPAN&gt;admin_group&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;\`&lt;SPAN&gt;azure_admin_group_dev&lt;/SPAN&gt;\`&lt;/SPAN&gt;)&amp;nbsp; will return:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;'\\`azure_admin_group_dev\\`'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 12:34:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115655#M45144</guid>
      <dc:creator>AsgerLarsen</dc:creator>
      <dc:date>2025-04-16T12:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using yml variables as table owner through SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115656#M45145</link>
      <description>&lt;P&gt;I guess that is a safe bet.&lt;BR /&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 12:42:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-yml-variables-as-table-owner-through-sql/m-p/115656#M45145</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2025-04-16T12:42:02Z</dc:date>
    </item>
  </channel>
</rss>

