A code template defines the default content that populates the code editor when you create a node. It includes information like the node type, creator, and creation time to help you identify and manage nodes. This topic describes the code template types supported by DataWorks and how to configure code templates.
Limitation
Only a Workspace Administrator can modify code templates. To allow other users to do so, grant them 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 target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.
At the bottom of the left-side navigation pane, click the
icon to open the Configure page.On the Configure page, click the Node Template tab to go to the Node Template page.
Configure the code template.
On the Node Template page, click Modify next to the desired Template to modify the code template for that node type. After you save the template, it applies to all new nodes of that type created in Data Studio. For information about the template types that DataWorks supports, see Supported code template types.
The following code provides an example of a code template for an ODPS SQL node.
--odps sql --********************************************************** --author: xxx --create time:2023-06-26 11:33:05 --**********************************************************
Supported code template types
You can use the following variables in a code template to record information about new nodes:
author: Records the node creator.createTime: Records the node creation time.
The following table describes the node types supported by DataWorks and the default code templates provided for each node type.
Engine type | Node type | Default template |
MaxCompute | The ODPS Script code template contains the following template variables: | |
The default content of the ODPS SQL code template contains the comment line | ||
The default code template for ODPS MR nodes is | ||
The default PyODPS 2 code template contains the following tip: | ||
The PyODPS 3 code template contains the following content: "Please try your best avoiding downloading massive data from MaxCompute. Related methods are | ||
EMR | | |
The EMR Shell code template contains the template variables | ||
The EMR Presto code template contains the following template variables and note:
| ||
| ||
EMR Trino | The EMR Trino code template contains the following content:
| |
The code template for EMR Hive nodes contains the template variables | ||
| ||
The default code template for EMR Spark SQL nodes contains a comment block that defines the | ||
CDH | CDH Hive | |
CDH Spark | | |
CDH MR | | |
CDH Presto | | |
CDH Impala | The CDH Impala code template contains the variables | |
Hologres | The default Hologres SQL code template contains a comment header that uses the | |
Others | | |
Example content of the ClickHouse SQL code template: asterisk separator lines at the top and bottom, with the two template variables | ||
|