If/else task branches
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:26 AM
Hi,
I have an If/else task, say A and two other tasks B and C.
For the false outcome I would like to execute task B. For the true branch I would like to execute task C followed with task B. What is the correct way to express the dependencies of B on the conditional branches?
Thank you in advance.
- Labels:
-
Workflows
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:50 AM
For sure one solution is to package everything in a separate job. Other options?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 05:32 AM
Hello @vanagnostopoulo!
You can handle this using the “Run if” conditions in Databricks Jobs to control how tasks run based on different branches. Here’s how you can set it up:
- Make Task B depend on both Task A (condition task) and Task C (true branch).
- Set Task B’s Run if to “All done”, this makes sure it runs after both A and C finish, no matter if they succeed or fail.
- For Task C, set its Run if to “All succeeded” on Task A, that way, it only runs when Task A succeeds and the condition evaluates to true.
So if Task A evaluates to false, Task B will run right after Task A. If it’s true, Task B will wait until Task C finishes before running. This setup keeps things clean and avoids needing to split tasks into a separate job.