To make a conditional judgment in a task flow, you can add a conditional branch node to the task flow. The subsequent tasks in the task flow can be executed only if the conditional branch node meets the specified condition. This topic describes how to configure a conditional branch node.

Prerequisites

A task flow is created. For more information, see Overview.

Scenarios

During the execution of a task flow, if the conditional expression of a conditional branch node evaluates to true, the subsequent tasks are executed. Otherwise, the subsequent tasks are not executed. You can apply a conditional branch node to the following or other similar scenarios:
  • Back up and delete data when the number of data entries reaches the specified value.
  • Send a notification when the sales amount meets the specified condition.
  • Check whether a specific file exists. If the file does not exist, create it.

Procedure

  1. Go to the details page of a task flow in the Data Management (DMS) console.
    1. Log on to the DMS console.
      Note To switch to the previous version of the DMS console, click the Return to old version icon in the lower-right corner of the page. For more information, see Switch to the previous version of the DMS console.
    2. In the top navigation bar, choose DTS > Task Orchestration.
      Note If you are using the previous version of the DMS console, move the pointer over the More icon in the top navigation bar and choose Data Factory > Task Orchestration (New).
    3. Click the name of a task flow. The details page of the task flow appears.
  2. In the Task Type list on the left side of the canvas, drag the Conditional Branch node to the blank area on the canvas.
  3. Click the Conditional Branch node.
  4. On the Node Information tab, configure the conditional expression of the conditional branch node.
    • Select an upstream variable or a status from the Variable Name drop-down list.
      Note
      • You can view the upstream variables, statuses, and system variables on the Input Variables tab on the left side.
      • If you select a status from the Variable Name drop-down list, you do not need to set the Relational Operator or Variable Value parameter.
    • Select a comparison operator from the Relational Operator drop-down list.
    • Enter the expected variable value or variable in the Variable Value field. The variable format is ${var_name}. For more information about variables, see Conditional branch variables.
    • Optional:Click an icon to the right of the conditional expression to add or delete an expression.
      • Plus icon: Add a conditional expression at the same level as the original expression and select a logical operator from the logical operator drop-down list to use between the new expression and the original expression.
      • Plus icon: Add a conditional expression and move it to the next level together with the original expression. Select a logical operator from the logical operator drop-down list to use between the new expression and the original expression.
      • Subtraction icon: Delete a conditional expression.
      Conditional expression
    Note
    • You can add up to three levels of conditional expressions.
    • You can view the judgment logic in the Preview section to the right of the Conditional Expression section.

Conditional branch variables

  • Upstream variables: Upstream variables are output variables from upstream nodes.
  • System variables.
    Variable Description Example
    sys.flow.start.timestamp The timestamp generated when the task is run. 2021-05-24T11:20:07.562+08:00
    sys.flow.start.year The year when the task is run. 2021
    sys.flow.start.month The month of the year when the task is run. 5
    sys.flow.start.day The day of the month when the task is run. 24
    sys.flow.start.hour The hour of the day when the task is run. 11
    sys.flow.start.minute The minute of the hour when the task is run. 20
    sys.flow.start.second The second of the minute when the task is run. 7
    sys.flow.start.milliseconds The millisecond of the second when the task is run. 562
    sys.flow.start.timezone The time zone. Asia/Shanghai
    sys.flow.biztime The data timestamp. By default, the data timestamp is the previous day of the day when the task is run. 1621740007562
    sys.flow.name The name of the task flow. dwd_activityDailyPV
    sys.node.name The name of the task. Single Instance SQL-1
  • Time variables: Use the default time variables or task flow variables. For more information about how to configure task flow variables, see Configure time variables.