All Products
Search
Document Center

DataWorks:Configure a code template

Last Updated:Aug 15, 2023

A code template provides the content that is displayed at the beginning of the code of a node to help you identify the node. The content includes the node type, the node creator, and the time when the node is created. You can use code templates to manage nodes from the business perspective. This topic describes the code template types supported by DataWorks and describes how to configure a code template.

Limits

Only a workspace administrator can modify code templates. If you want to modify a code template, you must be assigned the workspace administrator role. For more information, see Add a RAM user to a workspace as a member and assign roles to the member.

Configure a code template

  1. Go to the Template Management tab.

    1. Log on to the DataWorks console. In the left-side navigation pane, choose Data Modeling and Development > DataStudio. On the page that appears, select the desired workspace from the drop-down list and click Go to DataStudio.

    2. In the lower part of the left-side navigation pane of the DataStudio page, click the Settings icon.

    3. On the Settings page, click the Template Management tab.

  2. Configure a code template.

    On the Template Management tab, find the code template that you want to modify and click Change in the Actions column. In the Node Template dialog box, you can modify the code template based on your business requirements. After you modify and save the code template, the settings of the code template are displayed in the code of the node that you created in DataStudio. You can manage the node based on the settings. For information about code template types that are supported by DataWorks, see Supported code template types.

    The following figure shows the code template that is used for an ODPS SQL node. Code template

Supported code template types

When you define a code template, you can use variables to record the information about newly created nodes of a specific type. The following variables can be defined in the code template:

  • author: the node creator.

  • createTime: the time when a node is created.

The following table describes the node types that are supported by DataWorks and the default code templates that are provided for different node types.

Compute engine type

Node type

Default code template

MaxCompute

ODPS Script

ODPS Script

ODPS SQL

ODPS SQL

ODPS MR

ODPS MR

PyODPS 2

PyODPS 2

PyODPS 3

PyODPS 3

EMR

EMR MR

EMR MR

EMR Shell

EMR Shell

EMR Presto

EMR Presto

EMR Spark Streaming

EMR Spark Streaming

EMR Trino

EMR Trino

EMR Hive

EMR Hive

EMR Spark

EMR Spark

EMR Spark SQL

EMR Spark SQL

CDH

CDH Hive

CDH Hive

CDH Spark

CDH Spark

CDH MR

CDH MR

CDH Presto

CDH Presto

CDH Impala

CDH Impala

Hologres

Hologres SQL

Hologres SQL

Others

Shell

Shell

ClickHouse SQL

ClickHouse SQL

HTTP Trigger

HTTP Trigger