<?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: Conditional Logic in Databricks Asset Bundles using Go Templates in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149652#M53147</link>
    <description>&lt;P&gt;Intresting . I havent seen this go style templating with DABS . Typically you would define your variables in databricks.yml and then override the variable per environment .&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# databricks.yml

variables:
  job_pause_status:
    description: Pause/unpause job schedule by environment
    default: PAUSED   # sensible default

resources:
  jobs:
    job_name:
      name: job_name
      schedule:
        quartz_cron_expression: "0 0 8 * * ?"
        timezone_id: "UTC"
        pause_status: ${var.job_pause_status}&lt;/LI-CODE&gt;&lt;P&gt;Override per target&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;targets:
  dev:
    mode: development
    default: true
    variables:
      job_pause_status: PAUSED

  qa:
    mode: development
    variables:
      job_pause_status: PAUSED

  prd:
    mode: production
    variables:
      job_pause_status: UNPAUSED&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 03 Mar 2026 04:10:47 GMT</pubDate>
    <dc:creator>pradeep_singh</dc:creator>
    <dc:date>2026-03-03T04:10:47Z</dc:date>
    <item>
      <title>Conditional Logic in Databricks Asset Bundles using Go Templates</title>
      <link>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149647#M53145</link>
      <description>&lt;P&gt;I am defining a job using Databricks Asset Bundles (DABs) as follows:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;YAML&lt;/SPAN&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;resources:&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;jobs:&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;job_name:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;...&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;schedule:&lt;/SPAN&gt;
        {{ &lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;eq&lt;/SPAN&gt; &lt;SPAN class=""&gt;$&lt;/SPAN&gt;{&lt;SPAN class=""&gt;var.env&lt;/SPAN&gt;} &lt;SPAN class=""&gt;"prd"&lt;/SPAN&gt; }}
        &lt;SPAN class=""&gt;pause_status:&lt;/SPAN&gt; &lt;SPAN class=""&gt;"UNPAUSED"&lt;/SPAN&gt;
        {{ &lt;SPAN class=""&gt;else&lt;/SPAN&gt; }}
        &lt;SPAN class=""&gt;pause_status:&lt;/SPAN&gt; &lt;SPAN class=""&gt;"PAUSED"&lt;/SPAN&gt;
        {{ &lt;SPAN class=""&gt;end&lt;/SPAN&gt; }}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;I understand that Databricks bundle resource YAML files support Go-based templating. My goal was to deploy dynamic bundle resources based on the value of a bundle variable.&lt;/P&gt;&lt;P&gt;In the example above, I wanted to set the pause_status to "UNPAUSED" if the var.env value is "prd", and "PAUSED" for other development environments.&lt;/P&gt;&lt;P&gt;However, when I run databricks bundle validate, I encounter an error: did not find expected key. It seems that the template is unable to correctly reference the bundle variable, or the syntax is breaking the YAML structure.&lt;/P&gt;&lt;P&gt;As a side note, I have already confirmed that adding a pause_status variable per target in the Databricks configuration YAML works fine. I was simply curious if this alternative template-based approach is possible.&lt;/P&gt;&lt;P&gt;Has anyone successfully implemented this or found a workaround?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2026 02:17:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149647#M53145</guid>
      <dc:creator>Seunghyun</dc:creator>
      <dc:date>2026-03-03T02:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic in Databricks Asset Bundles using Go Templates</title>
      <link>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149652#M53147</link>
      <description>&lt;P&gt;Intresting . I havent seen this go style templating with DABS . Typically you would define your variables in databricks.yml and then override the variable per environment .&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# databricks.yml

variables:
  job_pause_status:
    description: Pause/unpause job schedule by environment
    default: PAUSED   # sensible default

resources:
  jobs:
    job_name:
      name: job_name
      schedule:
        quartz_cron_expression: "0 0 8 * * ?"
        timezone_id: "UTC"
        pause_status: ${var.job_pause_status}&lt;/LI-CODE&gt;&lt;P&gt;Override per target&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;targets:
  dev:
    mode: development
    default: true
    variables:
      job_pause_status: PAUSED

  qa:
    mode: development
    variables:
      job_pause_status: PAUSED

  prd:
    mode: production
    variables:
      job_pause_status: UNPAUSED&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Mar 2026 04:10:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149652#M53147</guid>
      <dc:creator>pradeep_singh</dc:creator>
      <dc:date>2026-03-03T04:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic in Databricks Asset Bundles using Go Templates</title>
      <link>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149718#M53161</link>
      <description>&lt;P&gt;also check this :&amp;nbsp;&lt;A href="https://community.databricks.com/t5/data-engineering/if-else-conditions-in-databricks-asset-bundles/td-p/89156" target="_blank"&gt;https://community.databricks.com/t5/data-engineering/if-else-conditions-in-databricks-asset-bundles/td-p/89156&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2026 16:43:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/149718#M53161</guid>
      <dc:creator>saurabh18cs</dc:creator>
      <dc:date>2026-03-03T16:43:27Z</dc:date>
    </item>
    <item>
      <title>Hi @Seunghyun, Go template syntax ({{if}}, {{eq}}, etc.)...</title>
      <link>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/150354#M53389</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/212394"&gt;@Seunghyun&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Go template syntax ({{if}}, {{eq}}, etc.) is only supported in bundle project templates, which are the .tmpl files used during "databricks bundle init" to scaffold new projects. It is not supported inside your regular databricks.yml configuration file, which is why you are seeing the "did not find expected key" validation error.&lt;/P&gt;
&lt;P&gt;There are several approaches to achieve per-environment conditional behavior for settings like pause_status without Go templates:&lt;/P&gt;
&lt;P&gt;APPROACH 1: TARGET-SPECIFIC OVERRIDES (RECOMMENDED)&lt;/P&gt;
&lt;P&gt;You can override resource settings directly within each target definition. Settings defined under a specific target merge with and override the top-level resource definitions:&lt;/P&gt;
&lt;PRE&gt;resources:
jobs:
  job_name:
    schedule:
      quartz_cron_expression: "0 0 8 * * ?"
      timezone_id: "UTC"
      pause_status: "PAUSED"

targets:
dev:
  mode: development
prd:
  resources:
    jobs:
      job_name:
        schedule:
          pause_status: "UNPAUSED"&lt;/PRE&gt;
&lt;P&gt;In this setup, the top-level definition defaults pause_status to PAUSED, and the prd target overrides it to UNPAUSED. The dev target inherits the default PAUSED value.&lt;/P&gt;
&lt;P&gt;APPROACH 2: USING CUSTOM VARIABLES&lt;/P&gt;
&lt;P&gt;You can define a custom variable and set its value per target:&lt;/P&gt;
&lt;PRE&gt;variables:
pause_status:
  description: "Whether job schedules are paused"
  default: "PAUSED"

resources:
jobs:
  job_name:
    schedule:
      quartz_cron_expression: "0 0 8 * * ?"
      timezone_id: "UTC"
      pause_status: ${var.pause_status}

targets:
dev:
  mode: development
  variables:
    pause_status: "PAUSED"
prd:
  mode: production
  variables:
    pause_status: "UNPAUSED"&lt;/PRE&gt;
&lt;P&gt;This is essentially what you mentioned is already working for you. This is a clean, idiomatic pattern and is the recommended way to parameterize values across targets.&lt;/P&gt;
&lt;P&gt;APPROACH 3: USING PRESETS (trigger_pause_status)&lt;/P&gt;
&lt;P&gt;If you want to control pause_status for all jobs and triggers at the target level without touching individual resource definitions, you can use the trigger_pause_status preset:&lt;/P&gt;
&lt;PRE&gt;targets:
dev:
  mode: development
  presets:
    trigger_pause_status: PAUSED
prd:
  mode: production
  presets:
    trigger_pause_status: UNPAUSED&lt;/PRE&gt;
&lt;P&gt;Note that development mode already pauses all schedules and triggers by default, so setting PAUSED explicitly in dev is optional. The presets approach is convenient when you have many jobs and want a blanket policy per environment.&lt;/P&gt;
&lt;P&gt;A NOTE ABOUT DEVELOPMENT MODE&lt;/P&gt;
&lt;P&gt;When you set mode: development on a target, Databricks Asset Bundles automatically pauses all schedules and triggers on deployed resources. So if your primary goal is simply to have schedules paused in dev and running in prod, using mode: development for dev and mode: production for prod may be all you need.&lt;/P&gt;
&lt;P&gt;REFERENCES&lt;/P&gt;
&lt;P&gt;- Databricks Asset Bundles variables: &lt;A href="https://docs.databricks.com/en/dev-tools/bundles/variables.html" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/bundles/variables.html&lt;/A&gt;&lt;BR /&gt;
- Bundle deployment modes: &lt;A href="https://docs.databricks.com/en/dev-tools/bundles/deployment-modes.html" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/bundles/deployment-modes.html&lt;/A&gt;&lt;BR /&gt;
- Bundle configuration reference: &lt;A href="https://docs.databricks.com/en/dev-tools/bundles/reference.html" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/bundles/reference.html&lt;/A&gt;&lt;BR /&gt;
- Bundle templates (where Go template syntax is supported): &lt;A href="https://docs.databricks.com/en/dev-tools/bundles/templates.html" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/bundles/templates.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;* This reply used an agent system I built to research and draft this response based on the wide set of documentation I have available and previous memory. I personally review the draft for any obvious issues and for monitoring system reliability and update it when I detect any drift, but there is still a small chance that something is inaccurate, especially if you are experimenting with brand new features.&lt;/P&gt;
&lt;P&gt;If this answer resolves your question, could you mark it as "Accept as Solution"? That helps other users quickly find the correct fix.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2026 05:57:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/conditional-logic-in-databricks-asset-bundles-using-go-templates/m-p/150354#M53389</guid>
      <dc:creator>SteveOstrowski</dc:creator>
      <dc:date>2026-03-09T05:57:33Z</dc:date>
    </item>
  </channel>
</rss>

