This topic explains the variables used in task orchestration.
Variable overview
Variables are dynamic values in a task flow, categorized as system variables, time variables, and non-time variables. You can reference any variable within a node using the${varName} syntax.
System variables
System variables are predefined values, such as the current task flow ID and the run time of the task flow.
If a custom variable shares a name with a system variable, its value overrides the system variable's value, giving the custom variable higher priority.
Time variables
-
Task flow variable (global variable): A task flow variable is calculated by applying a time offset to the data timestamp. By default, the data timestamp is the run time minus one day. As a global variable, it is available to all nodes in the current task flow.
NoteYou can configure a task flow variable on any node in a task flow. The configuration is automatically synchronized to all other nodes.
-
Node variable: A time variable created by applying a time offset to the built-in
bizdate(T-1) variable. A node variable is scoped to its defining node.For example, if the current date is August 22, 2023, and you apply a time offset of +1 day, the variable's value becomes August 23, 2023.
Non-time variables
-
Task flow constant (global variable): A task flow constant is a fixed value that can be used in all nodes within the current task flow.
-
Input variable: The system automatically populates input variables. You can reference an input variable in the SQL statements of the current node by using the ${var_name} syntax or as a conditional variable in a Conditional Branch node. Input variables include:
-
Upstream variable: An output variable from an upstream node.
-
Status variable: For more information, see Status variables.
-
System variable: For more information, see System variables.
-
-
Output variable: You define and assign a value to an output variable on the current node. Downstream nodes can then access and reference it.
For example, if you configure an output variable in a Script node, it can be referenced in the SQL statements of a downstream node.
-
Output variable from a Single Instance SQL node: You can use a Single Instance SQL node to define a result set from an SQL query. This result set forms a two-dimensional matrix. During variable definition, you can extract a single element or concatenate all values from a row or column.
-
Script output variable: If the last line of a script's output is a JSON object in the format
{ key1: value1, key2: value2, … }, and the values are of the String type, the script task automatically parses the JSON key-value pairs. This creates a variable namedkey, and the value of the variablekey is set to the corresponding value. You can reference the variable as${key}.For example, if the last line of the script is
echo {"hello": "world"}, the script task creates a variable namedhello, and the value ofhello is world.
Configure time variables
|
Parameter |
Description |
|
Variable name |
Enter the name of the custom variable. Note
To delete a configured variable, click the |
|
Variable rule |
Configure the rules for the time variable.
Note
After you configure a time variable, you can reference it in SQL statements using the |
Time formats
The following table describes the supported time format specifiers.
|
Specifier |
Description |
Example input |
Example output |
|
Era |
|
Gyyyy |
AD 2021 |
|
Year |
|
yyyy |
2021 |
|
Month |
|
MM |
08 |
|
Week |
|
ww |
13 |
|
Day |
|
D |
360 |
|
Day of week |
|
e |
1 |
|
AM/PM |
|
a |
AM |
|
Hour |
|
HH |
10 |
|
Minute |
|
m |
27 |
|
Second |
|
ss |
08 |
|
Time zone |
|
z |
UTC+08:00 |
Examples of combined time formats:
|
Example input |
Example output |
|
|
2021-08-12 |
|
|
20210801 |
|
|
11:05:21 |
|
|
20210812 11:05:21 |
System variables
|
Variable name |
Description |
Example |
|
sys.flow.start.timestamp |
The run time's timestamp. |
2021-05-24T11:20:07.562+08:00 |
|
sys.flow.start.year |
The run time's year. |
2021 |
|
sys.flow.start.month |
The run time's month. |
5 |
|
sys.flow.start.day |
The run time's day. |
24 |
|
sys.flow.start.hour |
The run time's hour. |
11 |
|
sys.flow.start.minute |
The run time's minute. |
20 |
|
sys.flow.start.second |
The run time's second. |
7 |
|
sys.flow.start.milliseconds |
The run time's milliseconds. |
562 |
|
sys.flow.start.timezone |
The run time's time zone. |
Asia/Shanghai |
|
sys.flow.biztime |
The data timestamp. By default, this is the run time minus one day. |
1621740007562 |
|
sys.flow.name |
The task flow name. |
dwd_activity_daily_pv |
|
sys.node.name |
The node name. |
Single Instance SQL-1 |
Status variables
|
Variable name |
Description |
|
all_success |
All upstream tasks ran successfully. |
|
all_failed |
All upstream tasks failed. |
|
one_success |
At least one upstream task ran successfully. |
|
one_failed |
At least one upstream task failed. |
You can use status variables in a Conditional Branch node to control whether the task flow runs subsequent tasks based on a specific run status.
icon.