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: 

Feature Request: Cross-job dependencies with business-date awareness

indradbxlearn
New Contributor III

Summary
Workflows can chain tasks inside one job, but there is no native way to say: “Run job X once per day, after jobs A, B, C, D and E have each completed successfully for the same business date, even though they are independent jobs with their own schedules.” We’d like native support for this.

The scenario

  • We have 5 dimension jobs: dimjob1 to dimjob5, each owned and scheduled independently.
  • We have one fact job, factjob1, which must run once per day, only after all 5 dimension jobs have succeeded for the current business date.
  • The dimension tables are also updated throughout the day by other jobs and manual processes. Those updates must not trigger or satisfy factjob1. Only the completion of dimjob1-5 counts.

Enterprise schedulers such as Tidal, Control-M and Autosys handle this with a simple job-level dependency.

Our current workaround

  1. Each dimension job writes a completion record (job name, business date, status) to a custom control table at the end.
  2. factjob1 has a gate task that checks all 5 records for today’s business date.
  3. An If/else condition task acts on the gate’s result.
  4. factjob1 is scheduled on a polling interval (e.g. every 15-30 minutes) because we can’t know when the dimension jobs will finish.
  5. An “already succeeded today” guard prevents duplicate runs.
  6. Custom alerting handles the case where dependencies aren’t met by the deadline.

Alternatives don’t fit either. A “Run Job” orchestrator forces us to merge the independent schedules and ownership into one pipeline, and table update triggers fire on any write, including the manual and ad hoc loads we need to ignore.

Why this is a problem

  • Six custom components to express one dependency rule.
  • Fragile: every dimension job must write its completion record correctly.
  • Rebuilt by every team in a slightly different way.
  • Polling wastes job runs and compute just to ask “are they done yet?”
  • Dependency status is invisible in the Workflows UI, so support teams can’t see why factjob1 hasn’t started.
  • Teams migrating from Tidal or similar tools have to redesign their dependencies, not just re-point them.

 

Proposed solution
Native job-level dependencies on a job’s trigger, for example (syntax is only a suggestion):

 
yaml
trigger:
  job_dependencies:
    jobs: [dimjob1, dimjob2, dimjob3, dimjob4, dimjob5]
    condition: ALL_SUCCEEDED
    window: DAILY              # business date / calendar window and timezone
    run_policy: ONCE_PER_WINDOW
    deadline: "08:00"          # alert if not satisfied by then

Key capabilities:

  • All-of-N job runs succeeded within a window (daily, or a custom business date).
  • Only job run outcomes count. Table writes from other processes are ignored.
  • Once-per-window execution, with no re-trigger on later reruns.
  • Support for independent schedules and owners, with no need to merge jobs.
  • Optional passing of the business date as a parameter to the downstream job.
  • SLA deadline alerting if dependencies aren’t met in time.
  • UI visibility of which upstream jobs are satisfied and which are pending.

Benefits

  • Six custom components shrink to a few lines of configuration.
  • No polling, no custom control tables, no convention for every job to follow.
  • Teams keep independent ownership and schedules.
  • Operations can see dependency status directly in the UI.
  • Migration from Tidal, Control-M and Autosys becomes much simpler.

Could you please log this as a feature request and let me know if it’s on the roadmap? Happy to share more detail or test an early version.

5 REPLIES 5

SumeshKashyap
Valued Contributor III

I can't speak to the roadmap, but you can remove two of your six components today. Put the table update trigger on your control table, not on the dimension tables. Only dimjob1-5 write to it, so manual and ad hoc dimension loads never fire factjob1, and you can drop the 15-30 minute polling schedule. If you want to stop relying on each job writing its record correctly, the gate can ask the Jobs API directly whether each job succeeded today.

 

1. Event-driven instead of polling

 

In factjob1 > Triggers, add a Table update trigger on ops.job_completion (it must be a Unity Catalog table). Set a short "wait after last change" so that two dimension jobs finishing close together cause one evaluation instead of two. Keep your gate task, condition task and "already succeeded today" guard. Each dimension completion now fires one cheap gate run, which no-ops until the 5th record lands, and then the fact load runs once. Also set max_concurrent_runs: 1 on factjob1.

 

2. Optional: gate on actual run outcomes instead of self-reported records

 

from databricks.sdk import WorkspaceClient

from datetime import datetime, time

from zoneinfo import ZoneInfo

 

w = WorkspaceClient()

tz = ZoneInfo("Europe/London")  # your business-date timezone

start_ms = int(datetime.combine(datetime.now(tz).date(), time.min, tz).timestamp() * 1000)

deps = {"dimjob1": 111, "dimjob2": 222, "dimjob3": 333, "dimjob4": 444, "dimjob5": 555}

 

pending = [name for name, jid in deps.items()

    if not any(r.state.result_state and r.state.result_state.value == "SUCCESS"

    for r in w.jobs.list_runs(job_id=jid, completed_only=True, start_time_from=start_ms))]

 

dbutils.jobs.taskValues.set("pending", ",".join(pending))

dbutils.jobs.taskValues.set("ready", not pending)

print("Waiting on: " + ", ".join(pending) if pending else "All dependencies met")

 

Point the condition task at {{tasks.gate.values.ready}}. The printed pending list shows in the run output, which gives support some visibility into why the fact load hasn't run. You still need something to fire the gate. Either keep a one-line completion write in each dimension job for the trigger, or keep a light schedule. Either way, "did it really succeed" now comes from the run history rather than from convention.

 

3. Deadline alert

 

Use a Databricks SQL alert on the control table, e.g. count(distinct job_name) < 5 where business_date = current_date() scheduled at 08:00, instead of custom alerting code.

 

For the native feature itself, the right route is the Ideas Portal or your account team. Job-level dependencies are a common request from teams migrating off Control-M and Tidal, so it's worth adding your vote there.

 

Docs: https://docs.databricks.com/aws/en/jobs/trigger-table-update

Jen_Evangelista
New Contributor II

Hi indradbxlearn, one edge case is worth making explicit in the gate: a successful run that started today is not necessarily a successful run for today’s business date. A backfill for an older date could satisfy a start_time_from=midnight test, while a run started before midnight for the required date could be missed. The Jobs API documents start_time_from as a filter on run start time, not on the business period processed. Also, completed_only includes completed runs; it does not mean successful runs.

I would pass business_date explicitly as a job parameter and evaluate the exact five required job IDs against that same value, retaining the successful run ID as evidence. Keep the existing once-per-business-date guard: max_concurrent_runs=1 serializes runs, but a second queued run still needs to see that the date was already consumed. Define how repairs and later reruns affect readiness, too.

That is an implementation proposal for the workaround, not a claim that the requested native dependency feature is available. It gives you a useful acceptance test for the feature request: an old-date backfill must not unlock today’s fact load.

Official sources:
Jobs run filters: https://docs.databricks.com/api/jobs/v2/list-runs
Explicit job parameters: https://docs.databricks.com/aws/en/jobs/job-parameters

indradbxlearn
New Contributor III

Thanks @SumeshKashyap and @Jen_Evangelista , this is very helpful. Here is where we’ve landed.

  • Table update trigger on the control table, not the dimension tables. Only dimjob1-5 write to it, so manual and ad hoc loads can’t fire factjob1, and polling goes away.
  • Gate checks actual run outcomes through the Jobs API, not self-reported records.
  • Pass business_date as an explicit job parameter and check all five job IDs against that same value, since start_time_from filters on run start time, not business date.
  • Filter explicitly on a SUCCESS result state, as completed_only only means the run finished.
  • Store the successful run ID per dimension job as evidence.
  • Keep the condition task and a once-per-business-date guard, with max_concurrent_runs: 1. The setting alone doesn’t stop a second queued run.
  • The 08:00 deadline alert becomes a Databricks SQL alert on the control table.
  • Still to decide: how repairs and reruns affect readiness, for example whether a rerun after factjob1 has already run for that date is ignored or flagged.

Remaining caveat: each dimension job must still write a row to the control table to fire the trigger. If a job succeeds but skips that write, the gate never runs, so we’ll add a light fallback schedule as a safety net.

Net result: this is workable, but we still maintain a control table, a gate task, a condition task, a once-per-date guard and an alert, plus a business-date parameter convention across five jobs, just to express “run factjob1 after dimjob1-5 succeed for the business date.” I have provided a feedback to databricks this as feature request for native job-level dependencies with business-date awareness. I will look forward from databricks on this.

SumeshKashyap
Valued Contributor III

@indradbxlearn 

Two suggestions for the open items. First, make the control-table write a standard final task in each dimension job, so the job can't succeed without writing its row. Second, for reruns: count repairs that finish before the fact load, and flag any upstream success that lands after the fact load instead of re-triggering it.

1. Closing the "succeeded but skipped the write" gap

Don't leave the write in each job's own code. Add the same small notebook as the last task of dimjob1-5, depending on all other tasks (run_if: ALL_SUCCESS, the default), with these task parameters:

job_id = {{job.id}}

run_id = {{job.run_id}}

business_date = {{job.parameters.business_date}}

The notebook just inserts those three values into the control table. Because it's a task in the job, a failed write fails the job run, so "job succeeded but no row" can't happen any more. The gate still checks the run outcome through the Jobs API, so a bad row can't unlock the fact load either. You can keep the fallback schedule, but it should now only catch real failures.

2. Repairs and reruns

- Repair or rerun before factjob1 has consumed the date: let it count. The gate just needs one SUCCESS run per job for that business_date, whichever attempt it was.

- Success after factjob1 has consumed the date: don't re-trigger. Your guard already blocks it. Flag it instead. When the gate fires for a date that's already consumed, compare that date's dimension runs with the run IDs you stored as evidence. If there's a newer successful run, write a STALE row (or raise an alert) so someone decides whether to reprocess.

- Reprocessing on purpose: add a force parameter (default false) to factjob1 that skips the guard. A reload of an old date then needs a manual run with business_date and force=true, and it never happens by accident.

That also gives you a clear acceptance test for the native feature: an old-date backfill or a late rerun must never unlock or re-run today's fact load on its own. Good luck with the feature request. I'll upvote it if you share the Ideas Portal link here.

Docs: https://docs.databricks.com/aws/en/jobs/dynamic-value-references and https://docs.databricks.com/aws/en/jobs/run-if

suranga
Databricks Partner

Nice design. One option for the gate: instead of paging through the Jobs API, query the jobs system tables. It's one SQL query and works across workspaces:

SELECT job_id FROM system.lakeflow.job_run_timeline WHERE job_id IN (<dimjob1..5 ids>) AND result_state = 'SUCCEEDED' AND job_parameters['business_date'] = :business_date GROUP BY job_id;

-- proceed only if this returns 5 rows

Filtering on the business_date parameter instead of the start time also covers the backfill edge case raised above.

Caveat: system tables are not real-time. Ingestion lag can be minutes or more, so keep a short retry in the gate, or keep the API check as a fallback right after the trigger fires.

Also, Lakeflow Jobs now supports multiple triggers per job (Beta), which may simplify combining the table-update trigger with a safety-net schedule.