tencent cloud

Tencent Cloud DataBuddy

IF ELSE Conditional Tasks

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-10-09 16:12:51
Diterjemahkan oleh AI
IF ELSE conditional tasks (condition nodes) are used to implement branching logic in workflows: based on the condition evaluation result, they determine whether downstream task chains are executed.

Overview

Condition nodes are commonly used to:
Trigger different business processes based on time dimensions, such as running settlement processes at the end of a quarter and reconciliation processes at the end of a month.
Select different processing paths based on upstream run results, such as proceeding to Link A on success or the alarm link on failure.
Dynamically determine the execution content based on external parameters.
For general configurations (task name, upstream dependencies, parameters, monitoring metrics, alarms, and failure and timeout policies), see Task General Configuration.

Prerequisites

You are already the workflow owner or have Manage permission.
Downstream tasks for conditional result branches already exist in the workflow or will be created.

Operation Steps

Step 1: Creating a Conditional Node

1. On the workflow canvas, click + Add Task.
2. Select IF ELSE as the task type.

Step 2: Configuring Conditions

Condition nodes support configuring multiple condition groups, with each group associated with different downstream tasks.

Adding Conditions

1. In the Condition Configuration area of the task configuration panel, click Add to open the condition configuration dialog.
2. Select Simple Mode or Advanced Mode.
3. After configuring the conditions, click OK.

Simple mode

Parameter
Description
Required
Parameter Value 1
Input box that supports constants and system built-in parameters, such as {{workflow.start_time.iso_date}} and {{tasks.<name>.values.<key>}}.
Yes
Operator
Single-select dropdown: == / != / Greater than / Less than / Greater than or equal to / Less than or equal to.
Yes
Parameter Value 2
Input box with the same rules as Parameter Value 1.
Yes
Supported Operators:
Operator
Term
Description
==
Equal to
String comparison
!=
Not equal to
String comparison
>
Greater than
Numeric comparison (floating point)
<
Less than
Numeric comparison (floating point)
>=
Greater than or equal to
Numeric comparison
<=
Less than or equal to
Numeric comparison
Note:
When == / != are used, parameter values are processed as strings. When > / < / >= / <= are used, they are processed as numeric (floating-point) values.

Advanced Mode

Describe the condition in the input box using a Python-style expression, up to 512 characters, for example:
{{tasks.upstream.values.month}} == 12 and {{workflow.start_time.day}} == 31

Associating Downstream Tasks

Parameter
Description
Required
Condition-associated task
Multi-select dropdown. Options are all tasks in the current workflow except the current task.
Yes
Condition description
Optional, up to 512 characters.
No
Note:
An associated task cannot be a direct or indirect upstream task of the condition node. Otherwise, the submission will be blocked with the message "Task graph cannot contain circular dependencies." The same associated task cannot be reused across multiple conditions.

Step 3: Connecting Nodes on the Canvas to Create Conditional Branches

In addition to the task configuration panel, condition configuration is also triggered when downstream tasks are connected to a condition node on the canvas:
1. Connect from the condition node to the downstream task.
2. The system automatically opens the condition configuration dialog, and Condition Associated Task selects the newly connected downstream task by default.
3. After completing the condition configuration, click OK.

Step 4: Managing the Condition List

The condition configuration area displays all configured conditions in a list:
Field
Description
Condition ID
Generated by the system
Condition
Simple mode or advanced mode expression
Condition-associated task
Name of the associated downstream task
Condition description
Description entered by the user
Operation
Edit/Delete
You can configure up to 50 conditions. After the limit is exceeded, the Add button becomes grayed out.

Step 5: Upstream Dependencies, Parameters, Monitoring Metrics, Alarms, and Failure and Timeout Policies

Refer to Task General Configuration. Alarms for condition nodes support start, success, failure, and duration alarms.

Step 6: Saving

Click Create Task or Save Task.
Note:
When a task is saved, if a downstream task associated in the condition configuration does not have the condition node configured as its upstream, the system automatically adds the upstream dependency.

Runtime Behavior

Condition Node Itself

Condition met: The node status is "Success", and execution continues to be triggered based on the downstream task's run conditions.
Condition not met: The node status is "Success" (condition calculation is normal), but downstream nodes under the condition-not-met branch (including indirect downstream nodes) are automatically set to the "Excluded from Run" status.

Downstream Task Run Details

Tasks that do not meet the conditions and are excluded from running are displayed on the run details page.
The current node is automatically excluded from running because the upstream condition nodes "task_name" and "task_name_2" do not meet the conditions.

Running Separately and Rerunning

Condition nodes support standalone runs or reruns, and the run results are displayed normally. Running a condition node alone does not trigger downstream execution.

Condition Node Run Details

The condition node run details page displays the condition list:
Column
Description
Condition ID
Consistent with configuration
Condition
Original condition
Condition parsing
Actual condition after parameter substitution, for example, 12 == 12
Condition-associated task
Associated task name (click to go to the configuration page)
Condition result
true / false (displayed after successful execution)
If the condition node itself fails:
The condition node failed to run. Failure reason: {critical error log}.

Use Limits

A single condition node can have up to 50 conditions configured.
An associated task cannot be a direct or indirect upstream task (to avoid circular dependencies).
The same downstream task cannot be associated repeatedly in multiple conditions.
The condition advanced mode expression can be up to 512 characters long.

FAQs

Q1: If there is an SQL task upstream of a condition node, how do I use the SQL output in a condition? Reference it through a parameter:
{{tasks.upstream_sql.output.first_row.month}} == 12
For details, see System Built-in Parameters.
Q2: When a condition is not met, downstream nodes are marked as "Excluded from Run". Can tasks further downstream continue to run?
If all upstream tasks of a further downstream task are excluded from running, the decision is made based on the Run Conditions of the downstream task. For example, if the run condition is set to All Completed, the task will be triggered. If it is set to All Successful, the task will enter the Upstream Failed state.
It is generally recommended to use the "No Failure and At Least One Success" run condition at branch convergence points to prevent excluded runs from propagating downstream.
Q3: What syntax is supported in advanced mode? Advanced mode supports Python conditional expression syntax, including:
Comparison operators: ==, !=, <, >, <=, >=
Logical operators: and, or, not
Parentheses () are used for grouping.
Python built-in functions (such as len(), str(), int(), and so on)
Keep expressions as simple as possible. Complex logic can be split into multiple simple conditions.

References

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan