If/else task branches

vanagnostopoulo
New Contributor III

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.

vanagnostopoulo
New Contributor III

For sure one solution is to package everything in a separate job. Other options?

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.