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
Go to the Template Management tab.
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, select the desired workspace from the drop-down list and click Go to Data Development.
In the lower part of the left-side navigation pane of the DataStudio page, click the icon.
On the Settings page, click the Template Management tab.
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.
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 | ||
EMR | ||
EMR Trino | ||
CDH | CDH Hive | |
CDH Spark | ||
CDH MR | ||
CDH Presto | ||
CDH Impala | ||
Hologres | ||
Others | ||