if else condition task doubt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 04:49 AM
Hi community,
The if else condition task couldn't be used as real if condition? Seems that if the condition goes to False the entire job will be stop. Is it a right behaviour?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 05:01 AM
Hi,
I found that the problem is here:
- task_key: get_email_infos
max_retries: 3
min_retry_interval_millis: 150000
depends_on:
- task_key: check_type_of_trigger
outcome: "true"
- task_key: check_status_to_schedule
outcome: "false"
...the `depends on` is sequential but since the first is not set from the flow instead the second yes, this task it's not run. How can I fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2025 05:32 PM
In Databricks workflows, the "if-else" condition and depends_on logic do not behave exactly like standard programming if-else statements. If a task depends on another task's outcome and that outcome does not match (for example, the condition is false when the workflow expects true for the dependency), then the dependent task will not run. This is expected behavior, but not the same as having alternative branches like in regular code, where you can control what happens on both success and failure branches.
Workflow Logic in Databricks
-
The
depends_onstatement withoutcomecreates conditional dependencies between tasks. -
If the dependency condition is not met, Databricks does not run the dependent task; it skips it, but the overall job does not fail unless you design it that way.
-
However, if your workflow branches only on
true(or only onfalse), tasks that depend on the opposite outcome will never run. -
Databricks workflows do not automatically switch control to an "else" branch. You must explicitly model both paths.
Why Is Task Skipped?
-
In your example,
get_email_infoswon't run if all itsdepends_onoutcomes aren't satisfied. -
If you want either
check_type_of_trigger= "true" orcheck_status_to_schedule= "false" to run the task, you must split the workflow to create separate tasks for each condition. -
If you want to have true "if-else" branching, you need both "true" and "false" outcomes, each leading to their respective downstream tasks.
How to Model True If-Else Branches
-
Use separate downstream tasks for each outcome, rather than combining them in a single task's dependency list.
-
For exclusive branching, introduce dummy or passthrough tasks to ensure each path is handled and only one runs based on the condition.
Key Points
-
Databricks conditional dependencies are not true "if-else"; they are gating mechanisms.
-
If a condition is unmet, the job does not automatically fail—it just skips downstream tasks gated by those dependencies.
-
To model "if-else" logic, split your flow so each branch has its own tasks and conditions.
For more details, see this Databricks forum discussion and Databricks documentation on Workflow dependencies.