Databricks ML Professional Practice Question 25: Bundle Variables per Target
Databricks Certified Machine Learning Professional · Test 3 · question 5 of 10
A retraining job must read from and write to dev_catalog in development and prod_catalog in production. Everything else about the job (tasks, cluster spec, schedule) is identical. The team currently maintains two near-duplicate bundle configuration files, and a change made to one was recently forgotten in the other.
What is the correct way to express this in a bundle?
Show answer and explanation
Answer:
Bundle variables are the supported way to keep one resource definition while letting values differ per environment. The job is declared once and refers to the catalog as ${var.catalog}; each target sets its own value in its variables block, and databricks bundle deploy -t prod substitutes the production value at deploy time. There is then exactly one place to change the job, which removes the class of bug the team just hit, and the per-environment difference is explicit and reviewable in the same file.
Option A automates the detection of a problem instead of removing it. A diff check on two files that are *supposed* to differ in one field is noisy and fragile, and it still requires the fix to be applied twice.
Option C makes correctness depend on an uncommitted local edit. Someone will eventually deploy to dev without editing, or commit the edit and deploy production against the dev catalog.
Option D moves environment configuration to run time and into a human's hands. A widget default is not enforced, the scheduled run has no operator to set it, and the deployed artifact no longer records which environment it targets.
Reference: Bundle variables and substitutions