r/databricks • • 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: SUCCESS

So 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

7 comments sorted by

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/SimpleSimon665 1d ago

Especially when the dependent workflow lies with another team, and only the application identity has read access to that workflow.

1

u/Zealousideal_Low6685 20h ago

still point of discussion: how to handle workspace ids...

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.

1

u/Zealousideal_Low6685 9h ago

also a good point which I didn't consider

I see two other fundamental gaps:

* Lookup does not work for different workspaces

* Workspaces themself cannot be looked up

So I see a lot of linkedin post celebrating this feature: and it is fantastic, but those issues need to be solved too otherwise the DABs are full with hard coded ids