<?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: Environment-Specific Schemas in SQL Files in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/environment-specific-schemas-in-sql-files/m-p/154750#M54134</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/147238"&gt;@DineshOjha&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best approach is parameterized SQL with widget-based defaults in your Python wrapper, wired to DABs target variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why this works on both fronts: Engineers run the notebook interactively and widget defaults kick in (dev values). In automated deployments, base_parameters from DABs override the widgets — no code changes, no separate files, no manual find-and-replace.&lt;/P&gt;&lt;P&gt;The core idea is to write your SQL files as templates using ${variable} placeholders (which DABs natively support in databricks.yml), but to also ship a companion "dev defaults" file that lets engineers run the SQL directly.&lt;/P&gt;&lt;P&gt;Hope this will help you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/147238"&gt;@DineshOjha&lt;/a&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;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2026 15:23:57 GMT</pubDate>
    <dc:creator>lingareddy_Alva</dc:creator>
    <dc:date>2026-04-16T15:23:57Z</dc:date>
    <item>
      <title>Environment-Specific Schemas in SQL Files</title>
      <link>https://community.databricks.com/t5/data-engineering/environment-specific-schemas-in-sql-files/m-p/154746#M54133</link>
      <description>&lt;DIV class=""&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN&gt;Hi Databricks Community,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We are looking for the recommended best practice for managing environment-specific configurations (catalogs and schemas) within our SQL files when using Databricks Asset Bundles.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Our Setup:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;We use Databricks Asset Bundles to package and deploy our projects.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Our bundle includes a Python wrapper that reads and executes a series of &lt;/SPAN&gt;&lt;SPAN&gt;.sql&lt;/SPAN&gt;&lt;SPAN&gt; files using &lt;/SPAN&gt;&lt;SPAN&gt;spark.sql()&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;These SQL files define our views and transformations.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;The Challenge:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Our SQL files often need to join tables across different schemas. For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;-- FILE: ./src/sql/create_my_view.sql&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN class=""&gt;&lt;SPAN&gt;CREATE&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN&gt;OR&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt; REPLACE &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;VIEW&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt; dev_catalog.notebooks_dev_schema.final_view &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;AS&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class=""&gt;&lt;SPAN&gt;SELECT&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    t1.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;,
    t2.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class=""&gt;&lt;SPAN&gt;FROM&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    dev_catalog.notebooks_dev_schema.first_notebook_table t1&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;JOIN&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    dev_catalog.new_dev_schema.new_table t2 
    &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;ON&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt; t1.id &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt; t2.id;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;We have two conflicting goals:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Developer Experience:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; We want our data engineers to be able to copy-paste and run this SQL directly in a notebook to test and debug it easily. This means the catalog and schema names should be present in the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Automated Deployment:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; When we deploy the bundle to a different environment (e.g., 'stage'), we need these names to change automatically. For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;dev_catalog&lt;/SPAN&gt;&lt;SPAN&gt; -&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;stage_catalog&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;notebooks_dev_schema&lt;/SPAN&gt;&lt;SPAN&gt; -&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;notebooks_stage_schema&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;new_dev_schema&lt;/SPAN&gt;&lt;SPAN&gt; -&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;new_stage_schema&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Question:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What is the officially recommended or most effective pattern in Databricks to handle this? How can we balance the need for runnable, testable SQL with the need for automated environment configuration during deployment with Bundles?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We've considered the below approaches&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Simple string replacement in our Python wrapper, but that makes the base SQL files non-runnable. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Using &lt;/SPAN&gt;&lt;SPAN&gt;USE CATALOG&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;USE SCHEMA&lt;/SPAN&gt;&lt;SPAN&gt;, but that doesn't solve for joins across multiple schemas.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a feature within Asset Bundles or a design pattern that elegantly solves this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance for your insights&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Apr 2026 14:43:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/environment-specific-schemas-in-sql-files/m-p/154746#M54133</guid>
      <dc:creator>DineshOjha</dc:creator>
      <dc:date>2026-04-16T14:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Environment-Specific Schemas in SQL Files</title>
      <link>https://community.databricks.com/t5/data-engineering/environment-specific-schemas-in-sql-files/m-p/154750#M54134</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/147238"&gt;@DineshOjha&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best approach is parameterized SQL with widget-based defaults in your Python wrapper, wired to DABs target variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why this works on both fronts: Engineers run the notebook interactively and widget defaults kick in (dev values). In automated deployments, base_parameters from DABs override the widgets — no code changes, no separate files, no manual find-and-replace.&lt;/P&gt;&lt;P&gt;The core idea is to write your SQL files as templates using ${variable} placeholders (which DABs natively support in databricks.yml), but to also ship a companion "dev defaults" file that lets engineers run the SQL directly.&lt;/P&gt;&lt;P&gt;Hope this will help you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/147238"&gt;@DineshOjha&lt;/a&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;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2026 15:23:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/environment-specific-schemas-in-sql-files/m-p/154750#M54134</guid>
      <dc:creator>lingareddy_Alva</dc:creator>
      <dc:date>2026-04-16T15:23:57Z</dc:date>
    </item>
  </channel>
</rss>

