cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Asset Bundles Job If Condition

kunex
New Contributor

Hi

I am trying to use Asset Bundles to deploy a job with email notifications active only on production environment.
I tried to use such if statement but it does not seem to do anything.

resources:
  jobs:
    Master_Load:
      name: Master Load
      email_notifications:
        ${{ if eq(${var.env}, 'prd') }}:
          on_failure:
            - user1@smth.com
            - user2@smth.com

Is it possible to even use if statements in a job definition?

Best! 

1 ACCEPTED SOLUTION

Accepted Solutions

szymon_dybczak
Contributor III

Hi @kunex ,

You don't have to use if condition. The recommended approach is to use define "shared" configuration at the top level resources mapping and then when you need environment specific configuration use targets top level-level mapping to override configuration.
The settings in the top-level workspaceartifacts, and resources mappings are used if they are not specified in a targets mapping, but any conflicting settings are overridden by the settings within a target.

szymon_dybczak_0-1728569334806.png

 

Databricks Asset Bundle configuration | Databricks on AWS

View solution in original post

3 REPLIES 3

szymon_dybczak
Contributor III

Hi @kunex ,

You don't have to use if condition. The recommended approach is to use define "shared" configuration at the top level resources mapping and then when you need environment specific configuration use targets top level-level mapping to override configuration.
The settings in the top-level workspaceartifacts, and resources mappings are used if they are not specified in a targets mapping, but any conflicting settings are overridden by the settings within a target.

szymon_dybczak_0-1728569334806.png

 

Databricks Asset Bundle configuration | Databricks on AWS

Thanks @szymon_dybczak 
Here it is not that simple, it is not a simple variable but two emails starting with a dash thus i was wondering if i can use if statement, which was btw suggested incorrectly by chatgpt 🙂
As a walkaround i could use a variable based on a single email which would be a distribution group containing those people.

kunex
New Contributor

Okay i made it work with a variable, it was pretty easy. The variable accepted multiline text easily.
Thanks!

databricks.yml

targets:
  dev:
    mode: development
	...
    variables:
      notifications:
        default: 
          - user1@smth.com
          - user2@smth.com

job:

resources:
  jobs:
    Master_Load:
      name: Master Load
      email_notifications:
        on_failure:
          ${var.notifications}
        on_duration_warning_threshold_exceeded:
          ${var.notifications}



Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group