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: 

Databricks asset bundles and Dashboards - pass parameters depending on bundle target

erigaud
Honored Contributor

Hello everyone !

Since Databricks Asset Bundles can now be used to deploy dashboards, I'm wondering how to pass parameters so that the queries for the dev dashboard query the dev catalog, and the dashboard in stg query the stg catalog etc.

Is there any way to do this ? 

1 REPLY 1

Alberto_Umana
Databricks Employee
Databricks Employee

Hi @erigaud,

Here’s how you can achieve this:

 

Define Variables in the Bundle Configuration: You can define custom variables in your databricks.yml file to hold the catalog names for different environments. For example:

 

variables:

   catalog_name:

     description: "The catalog name to use for the environment"

     default: "dev_catalog"

 

Use Targets to Override Variables: You can specify different values for these variables in the targets section of your bundle configuration. This allows you to set different catalog names for different environments (e.g., dev, stg, prod).

 

targets:

   dev:

     default: true

     variables:

       catalog_name: "dev_catalog"

   stg:

     variables:

       catalog_name: "stg_catalog"

   prod:

     variables:

       catalog_name: "prod_catalog"

 

Reference Variables in SQL Queries: In your SQL queries within the dashboards, you can reference these variables to dynamically set the catalog name. For example

 

SELECT * FROM ${var.catalog_name}.schema_name.table_name

Please refer to: https://docs.databricks.com/en/dev-tools/bundles/settings.html

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