Dependency Between Jobs in Databricks
Create a multi-task Databricks job to organize related workloads; it can include tasks that run in parallel. This is the simplest way to run notebooks, pipelines, SQL, or other workloads in a defined order. For separately managed workloads, plan a single clear sequence before selecting an orchestration design.
How Databricks Job Dependencies Work
A Databricks job can contain one task or many tasks. A multi-task job can organize tasks that run in sequence or in parallel:
- A task with no dependencies can start when the job run begins.
- A task with one dependency waits for that upstream task.
- A task with multiple dependencies waits until Databricks can evaluate all of them.
- Independent tasks can run in parallel, subject to available compute and job concurrency settings.
- A circular dependency is not valid: Task A cannot depend on Task B if Task B eventually depends on Task A.
For example, a typical ETL workflow might look like this:
ingest_customers ─┐
├── validate_data ──> publish_gold_tables
ingest_orders ────┘
validate_data waits for both ingestion tasks. publish_gold_tables waits for validation.
A dependency controls execution order. It does not automatically transfer data from one task to another. Pass data through a storage location or another explicit interface between tasks.
Use one multi-task job when the tasks belong to one logical workflow and should share a single run history, schedule, and dependency graph.
How to Create a Multi-Task Job With Dependencies
Choose the design before creating tasks. This avoids building separate scheduled jobs that accidentally overlap or trigger duplicate work.
| What You Need | Best Databricks Design |
|---|---|
| Run one notebook after another | Tasks in one multi-task job |
| Run a task after two or more upstream tasks succeed | One downstream task with multiple dependencies |
| Continue after at least one upstream branch succeeds | Multiple dependencies with an appropriate run condition |
| Start an existing job from another workflow | A Run Job task in a parent job |
| Pass a small status value or path between tasks | Task values or job parameters |
| Process large outputs between tasks | Persist the output in Delta tables or cloud storage |
Step 1: Draw the Task Graph
- List each unit of work as one task: ingestion, validation, transformation, publishing, notification, and so on.
- Mark which tasks can safely run at the same time.
- Draw an arrow from each prerequisite task to the task that needs it.
- Keep task keys stable and descriptive, such as
ingest_orders,validate_orders, andpublish_orders.
Do not create a dependency just because two tasks use the same cluster. Shared compute is not an execution dependency, and it can make unrelated failures harder to diagnose.
A simple workflow might be:
load_raw_data ──> transform_data ──> publish_data
A fan-in workflow, where one task waits for two upstream tasks, might be:
load_customers ──┐
├── build_customer_orders
load_orders ─────┘
Step 2: Create the Job and Add Every Task
- In the Databricks workspace, open Workflows > Jobs.
- Select Create job.
- Add the first task and configure the workload it will run.
- Give the task a clear task key.
- Select the compute for that task, such as serverless compute, an existing cluster, or a job cluster.
- Add the remaining tasks to the same job.
Each task needs its own executable workload and compute configuration. You can use the same job cluster definition across tasks when that suits the workload, but configure dependencies separately.
If you manage jobs as code, make the relationship between tasks clear in the job definition. This example shows a job bundle with transform_data waiting for load_raw_data:
resources:
jobs:
daily_pipeline:
name: daily-pipeline
tasks:
- task_key: load_raw_data
notebook_task:
notebook_path: ./src/load_raw_data.py
- task_key: transform_data
depends_on:
- task_key: load_raw_data
notebook_task:
notebook_path: ./src/transform_data.py
The value under task_key in depends_on must exactly match the upstream task key. A mismatch leaves the job configuration invalid or creates a dependency on the wrong task after a later edit.
Step 3: Add Dependencies to the Downstream Task
- Select the task that should wait.
- Find its dependency setting, typically labeled Depends on.
- Add the upstream task or tasks.
- Save the job.
For a linear pipeline, select one upstream task:
transform_data depends on load_raw_data
For a task that must wait for two ingestion tasks, add both:
build_customer_orders depends on load_customers
build_customer_orders depends on load_orders
In this example, build_customer_orders follows both upstream ingestion tasks.
Step 4: Set the Run Condition
A dependency answers “what must finish first?” A run condition answers “which upstream outcomes allow this task to run?”
Choose a condition that matches the task’s purpose:
- All succeeded: Run only after every dependency succeeds. This is the normal choice for transformations and publishing.
- At least one succeeded: Run if any upstream dependency succeeds. Use this for an aggregation or fallback branch that can work with partial input.
- None failed: Run when no dependency failed. This can allow a task to proceed when an upstream task was intentionally excluded.
- All done: Run after all dependencies reach a terminal state, whether they succeed, fail, or are skipped. Use this for cleanup, audit logging, or status reporting.
- At least one failed: Run an error-handling task when any upstream task fails.
- All failed: Run only when every upstream dependency fails.
Use All succeeded for any task that creates a trusted downstream dataset. A notification or cleanup task often needs All done instead, because it must run even if the main processing task fails.
Step 5: Pass the Output the Next Task Needs
Dependencies guarantee order, not shared variables or notebook state.
For durable pipeline data, write results to a Delta table or a controlled storage path. Then have the downstream task read that location. This is usually the right approach for datasets, records, and files.
For a small value such as a generated path, version identifier, or row count, set a task value in a Python task:
dbutils.jobs.taskValues.set(key="output_path", value=output_path)
Use the generated value as an explicit input in the downstream task configuration:
{{tasks.load_raw_data.values.output_path}}
Use job parameters for values that apply to the entire run, such as an environment name, processing date, or source system. Use task values for results produced during that specific run.
Step 6: Save, Run, and Inspect the Workflow
- Save the job configuration.
- Select Run now.
- Open the job run details page.
- Confirm that upstream tasks run first.
- Confirm that downstream tasks remain pending until their dependency conditions are met.
- Open each task run to review logs, inputs, and outputs.
A successful test should show the intended graph rather than just green task statuses. Check that independent tasks overlap when expected and that downstream tasks do not begin early.
Run a Job After Two Other Jobs Finish
If the two upstream workloads are currently separate Databricks jobs, the cleanest design is usually a new parent orchestration job.
Create a parent job with:
run_customer_job ──┐
├── publish_reporting_tables
run_order_job ─────┘
Configure run_customer_job and run_order_job as Run Job tasks. Treat the two called jobs as the upstream work for the reporting step. Then make publish_reporting_tables depend on both Run Job tasks.
Use the default All succeeded condition when publishing requires successful output from both child jobs.
This design gives you one parent job run to inspect when the overall workflow fails. It also prevents a reporting task from starting just because one of the two source jobs happened to finish first.
Avoid leaving independent schedules enabled on child jobs if the parent job is supposed to control their timing. Otherwise, the child job can run both on its own schedule and when invoked by the parent, creating duplicate processing or conflicting writes.
If the two jobs are already running independently rather than through a shared workflow, coordinate their completion before starting the final workload. In that situation, redesign them under a parent job or use an external orchestrator that can query both run states before starting the final workload.
Trigger a Separate Databricks Job From a Current Job
Use a Run Job task when the downstream workload must remain a separately managed job.
This is useful when:
- The child job is shared by several workflows.
- The child job has its own task graph.
- A team owns the child job separately.
- You want the parent workflow to wait for the child job’s result.
To set it up:
- Create or identify the job to be called.
- In the parent job, add a task with the Run Job task type.
- Select the child job.
- Add dependencies to the Run Job task if the child job should not start immediately.
- Make later parent tasks depend on the Run Job task.
- Pass explicit job parameters when the child job needs run-specific input.
For example:
prepare_source_data
|
v
run_quality_checks_job
|
v
publish_to_consumers
Here, run_quality_checks_job is a Run Job task. publish_to_consumers starts only after the called quality-check job succeeds.
Do not use a notebook to call the Jobs API merely to create a basic dependency between related tasks. For a basic dependency between related tasks, choose a workflow design with a clear sequence instead of custom polling code.
Use Run Conditions, Parameters, and Notifications
Run conditions route failures and final audits, while parameters keep run-specific inputs consistent across tasks.
Add a Failure Notification Path
A reliable production job usually needs a branch that runs when processing fails.
For example:
ingest_data ──> transform_data ──> publish_data
|
└──> notify_failure
The diagram is a failure branch: configure notify_failure to depend on both ingest_data and transform_data, using At least one failed. The notification task can send a message, write an incident record, or invoke a remediation workflow.
Use All done for a final audit task that must record the final state regardless of success or failure.
Keep Retry Logic Inside the Failing Task
Configure retries on the task that can fail transiently, such as a task reading an external API or warehouse. Do not duplicate the task as a separate branch solely to retry it.
This preserves a simple dependency graph:
extract_data ──> transform_data ──> publish_data
The extraction task can retry before Databricks evaluates whether transform_data may run.
Use Parameters for Run-Specific Inputs
A job parameter is suitable for input that should be consistent across tasks in one run:
processing_date=2026-11-06
environment=production
Pass parameters into notebooks, scripts, SQL tasks, or called jobs as appropriate for the task type. A downstream task should read the same run parameter rather than independently calculating a date, especially when jobs can be retried or manually rerun.
Confirm and Troubleshoot Job Dependencies
Use the job run graph as the first diagnostic tool. It shows whether the problem is the dependency itself, the run condition, compute availability, or an upstream failure.
| Symptom | Likely Cause | Fix |
|---|---|---|
| A downstream task never starts | An upstream task failed, was skipped, or does not satisfy the run condition | Review upstream task states and choose a run condition that matches the intended behavior |
| A task starts before another workload is done | The workloads are separate jobs without a parent orchestration dependency | Put both under one multi-task job or call both from a parent job |
| A task is skipped | Its dependencies completed, but the selected run condition was not met | Check the task’s Run if setting |
| A downstream notebook cannot find an expected value | The dependency was configured, but data was not persisted or passed | Use Delta storage, job parameters, or task values |
| The same pipeline runs twice | A child job has its own schedule and is also launched by a parent job | Disable or redesign overlapping triggers |
| Two tasks run one after another unexpectedly | An unnecessary dependency was added | Remove the dependency so independent tasks can run concurrently |
Use this short verification checklist before relying on a new workflow:
- Every task key is unique and descriptive.
- Every downstream task lists the correct upstream task keys.
- Each critical data task uses All succeeded unless partial results are intentional.
- Failure notifications use a failure-aware run condition.
- Each task has a valid compute configuration.
- Data is exchanged through a durable location, parameters, or task values.
- A manual test run shows the expected task graph and statuses.
Next, build the smallest version of your workflow with two tasks, run it manually, and inspect the graph before adding schedules or failure branches. Databricks includes Lakeflow Jobs training as part of its data engineering learning path for deploying scheduled workloads.
Frequently Asked Questions
How do I add another job as the next step in an Azure Databricks job?
Add it as another task in the same multi-task job when it is part of the same workflow. In Workflows > Jobs, add the task, then set its Depends on value to the prior task. Use a Run Job task instead when the next step must invoke an existing separate job.
Can a Databricks job run after two other jobs finish?
Yes, by using a parent job with two Run Job tasks and a third downstream task that depends on both. Set the downstream task to All succeeded when it should run only after both child job runs complete successfully. This creates an AND dependency rather than relying on independent job schedules.
How do I trigger a Databricks job only if another job succeeds?
Put both workloads in one multi-task job, or create a parent job that calls the other job with a Run Job task. Make the dependent task wait on that task and use the All succeeded run condition. The dependent task is then skipped if the upstream task or called job fails.
What is the difference between a dependency and a trigger in Databricks?
A dependency controls order between tasks in the same job run. A trigger starts a job run rather than determining the sequence of tasks within that run. A job-completion requirement is best modeled as a task dependency or a parent job invoking child jobs, not as two unrelated schedules.
Can Databricks tasks run in parallel?
Yes. Tasks without dependencies can run in parallel within the same job run when compute and concurrency settings allow it. Add dependencies only where one task needs another task’s successful completion or output.
Can one Databricks task pass a Python variable directly to another task?
No. Separate tasks do not share Python process memory, even when they use related compute. Use a Delta table or storage location for datasets, task values for small run outputs, and job parameters for shared inputs.
