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:ย 

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.

2 REPLIES 2

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.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now