Configure node context

更新时间:
复制 MD 格式

The node context feature automatically passes parameters between upstream and downstream nodes. Supported parameter types include constants, variables, and query results from upstream nodes, enabling dynamic task scheduling and execution.

Limits

  • Product edition: The Add assignment parameter feature (used to pass query results) is available only in DataWorks Standard Edition and higher.

  • Node type restrictions: Only specific node types support passing query results using an assignment parameter. Supported types include EMR Hive, EMR Spark SQL, ODPS Script, Hologres SQL, AnalyticDB for PostgreSQL, ClickHouse SQL, and MySQL nodes.

How it works

Node context parameters pass values by defining an output parameter on the upstream node (provider) and referencing it on the downstream node (consumer).

image
  • Upstream node (provider): Generates a value and passes it as an output parameter. You can provide the value in one of the following two ways:

    • Configure standard output parameters: In the Output Parameters section of the upstream node, define a parameter and assign a value to it. The value can be a constant, such as 'abc', or a system context variable, such as ${status}.

    • Configure assignment output parameters: The system captures the result of the last query in the node's code (for example, SELECT 'table_A';) and assigns it to a built-in output parameter named outputs. The value of this parameter is then passed to downstream nodes. The parameter value depends on the execution result of the code. This method is supported by assignment nodes and some SQL-based nodes.

  • Downstream node (consumer): Receives and uses the value provided by the upstream node.

    1. Establish a scheduling dependency: Configure a scheduling dependency on the upstream node.

    2. Configure an input parameter: In the Input Parameters section of the downstream node, add an input parameter and set its value source to an output parameter of the upstream node.

    3. Reference the value in code: In the code of the downstream node, reference the received value in the format ${input_parameter_name}. For example, if the upstream node passes the value table_A, the code SELECT * FROM ${input}; is resolved to SELECT * FROM table_A; at runtime.

Access the parameter configuration area

  1. Log on to the DataWorks console, switch to the desired region, and in the left-side navigation pane, choose Data Development and O&M > Data Development. Select the target workspace from the drop-down list and click Go to Data Development.

  2. On the Data Studio panel, double-click the target node to open its editing page.

  3. Click Properties on the right side, and then click image on the right side of the Node Context section to enter the node context parameter configuration area.

Configure output parameters

When you configure output parameters for the current node in the node context area, you can configure them based on your business requirements.

Configure standard output parameters

To pass the parameter information configured on an upstream node to a downstream node, see the following content.

Parameter

Description

No.

The number is controlled by the system and increments automatically.

Parameter name

Specify a custom name for the output parameter.

Type

Supports constants and variables. You can select a type based on your business requirements.

Value

The value of the output parameter. Supported value types include constants and variables:

Description

A brief description of the parameter.

Source

The source of the current parameter.

Options include System Added, Parsed From Code, and Manually Added.

Actions

Supports Save, Edit, and Delete actions.

Note

Editing and deletion are not supported when downstream nodes depend on the parameter. Before a downstream node references an upstream node, check carefully to ensure that the upstream output is defined correctly.

After you configure the parameters, click Save in the Actions column.

Configure assignment output parameters

To pass the query result of the current task as a parameter to downstream tasks, see the following content.

  1. Locate the section of the node.

  2. Click Add assignment parameter to add an output assignment parameter with a single click.

Note

After you click Add assignment parameter, the assignment parameter passes the query result of the current node to downstream nodes that reference the parameter. If the result is empty, the current node is not blocked, but the downstream nodes that reference the parameter may fail.

The downstream node must add the assignment parameter of the upstream node as an input parameter. Its usage is similar to that of an assignment node. For more information, see Assignment node.

After you configure the output parameters of the current node, you can view the output name added by the system in on the configuration page. Downstream nodes can use this output name to bind the dependency with the current node.

Configure input parameters

Configure input parameters for the current node in the node context area. This allows you to obtain output parameters from upstream nodes for use in the current node.

Note
  • The input parameters of a node can be used to obtain the output parameters of its upstream nodes. After an input parameter is added, you can use it in the code of the current node in the same way that you use a scheduling parameter variable in code.

  • Only after the current node is set to depend on an upstream node can you add the output of that upstream node as an input parameter of the current node in the Input Parameters area.

  1. An output parameter has been configured on the upstream node. See Configure output parameters.

  2. Set up the upstream-downstream dependency.

    1. On the editing page of the downstream node, click Properties on the right side.

    2. In the dialog box after Node Output in , enter and select the output name that you specified when you configured the upstream node in Configure output parameters.

    3. Click Add.

  3. Configure input parameters on the downstream node.

    In the Node Context area, click Add Input Parameter. Configure the parameters based on the following table:

    Parameter

    Description

    No.

    The number is controlled by the system and increments automatically.

    Parameter name

    Specify a custom name for the input parameter. You can later reference the parameter information passed from upstream by using this parameter name on the node editing page.

    Value source

    The value of the parameter comes from an output parameter of the upstream node. The actual value is the actual output result of the upstream node.

    Description

    You can enter a brief custom description of the parameter.

    Parent node ID

    Automatically parsed from the upstream node.

    Source

    The source of the current parameter.

    Options include System Added, Parsed From Code, and Manually Added.

    Actions

    Supports Save, Edit, and Delete actions.

  4. After you configure the parameters, click Save in the Actions column.

Use input parameters in downstream nodes

To use the defined input parameters in a node, use the same method as for other system variables. Reference them in the format ${input_parameter_name}. The following section uses a Shell node as an example to describe how to reference the parameters.

image

Note

When you run the task, run the workflow that contains the upstream and downstream nodes so that the upstream and downstream nodes run in sequence. Otherwise, the input parameters used by the downstream node are invalid.

Global variables supported by the system

  • System variable

    System variable

    Description

    ${projectId}

    Project ID.

    ${projectName}

    MaxCompute project name.

    ${nodeId}

    Node ID.

    ${gmtdate}

    00:00:00 on the day of the scheduled time of the instance, in the format yyyy-MM-dd 00:00:00.

    ${taskId}

    Task instance ID.

    ${seq}

    The sequence number of the task instance, which indicates its order among the instances of the same node on the current day.

    ${cyctime}

    Scheduled time of the instance.

    ${status}

    Status of the instance: SUCCESS or FAILURE.

    ${bizdate}

    Business date.

    ${finishTime}

    End time of the instance.

    ${taskType}

    Run type of the instance: NORMAL, MANUAL, PAUSE, SKIP (dry run), UNCHOOSE, or SKIP_CYCLE (weekly or monthly dry run).

    ${nodeName}

    Node name.

  • For information about other parameter settings, see Scheduling parameter formats.