3 weeks ago
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
Enterprise schedulers such as Tidal, Control-M and Autosys handle this with a simple job-level dependency.
Our current workaround
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
Proposed solution
Native job-level dependencies on a job’s trigger, for example (syntax is only a suggestion):
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 thenKey capabilities:
Benefits
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.
3 weeks ago
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
2 weeks ago
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
2 weeks ago
Thanks @SumeshKashyap and @Jen_Evangelista , this is very helpful. Here is where we’ve landed.
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.
2 weeks ago
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
2 weeks ago
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.