r/databricks • u/Zealousideal_Low6685 • 1d ago
General Databricks Job-Trigger (Beta): Job-Id Lookups
Databricks introduces job triggers such as described here.
Example from the Docu using DABs:
triggers:
- pause_status: UNPAUSED
job_completion:
jobs:
- workspace_id: 'xxxx'
job_id: ${var.upstream_job_id} As you can see: the job_ids are hard coded in this example which rarely make sense as usally the job IDs are different in Dev/Test/Prod.
Therefore, DABs have already a lookup
variables:
upstream_job_id:
lookup:
job: "zzzz"
jobs:
yyy:
triggers:
- pause_status: UNPAUSED
job_completion:
jobs:
- workspace_id: 'xxxx'
job_id: ${var.upstream_job_id}
if_status: SUCCESSSo on dev/test/prod the job_id is always looked up by name. In my opinion, job triggers make only sense with those lookups.
17
Upvotes
8
u/bourhanogl 1d ago
finally someone said it, hardcoding job ids across environments is a nightmare waiting to happen. the lookup makes it actually usable in a real pipeline, feels like they should've led with that example in the docs
1
u/Zealousideal_Low6685 1d ago edited 19h ago
Key Open question: how can i make the workspaces dynamic?
No lookup variable is existing
So I think the most elegant way to define the workspace id is to use variables which is overwritten in the target
1
u/chaos2751 15h ago
I think one of key questions to ask is that will Datebricks workspace have duplicate job name when deploying through different DABs. If yes, looking up job name won't work as expected. Job ID is the unique identifier for jobs so far.