All Products
Search
Document Center

DataWorks:Configure code templates

Last Updated:Sep 04, 2026

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

  1. Go to the Template Management tab.

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

    2. At the bottom of the left-side navigation pane, click the Settings icon to open the Configure page.

    3. On the Configure page, click the Node Template tab to go to the Node Template page.

  2. 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

ODPS Script

The ODPS Script code template contains the following template variables: ${author} (author) and ${createTime} (creation time). The template content is wrapped in comment separator lines.

ODPS SQL

The default content of the ODPS SQL code template contains the comment line --odps sql, along with the template variables ${author} (author) and ${createTime} (creation time). The lines are separated by asterisk divider lines. After you edit the template, click Save.

ODPS MR

The default code template for ODPS MR nodes is -odps mr, and contains the ${author} (author) and ${createTime} (creation time) variable placeholders. In the Code Template dialog, edit the template and click Save.

PyODPS 2

The default PyODPS 2 code template contains the following tip: Please try your best avoiding downloading massive data from MaxCompute. Related methods are open_reader of tables or instances, and to_pandas of DataFrames. It is recommended to use PyODPS DataFrame created from MaxCompute tables, or MaxCompute SQL directly. Reference: https://developer.aliyun.com/article/745029. In the Code Template dialog, edit the template and click Save, or click Cancel to discard the changes.

PyODPS 3

The PyODPS 3 code template contains the following content: "Please try your best avoiding downloading massive data from MaxCompute. Related methods are open_reader of tables or instances, and to_pandas of DataFrames. It is recommended to use PyODPS DataFrame created from MaxCompute tables, or MaxCompute SQL directly. Reference: https://developer.aliyun.com/article/745029".

EMR

EMR MR

--EMR MR
--**********************************************************--
--author:${author}
--create time:${createTime}
--EMR MR node can only run on exclusive resource groups.
--**********************************************************--

EMR Shell

The EMR Shell code template contains the template variables ${author} and ${createTime}, along with the note that EMR Shell nodes can only run on exclusive resource groups.

EMR Presto

The EMR Presto code template contains the following template variables and note:

  • --author:${author}

  • --create time:${createTime}

  • --EMR Presto node can only run on exclusive resource groups.

EMR Spark Streaming

--EMR Spark Streaming
--***************************************************--

--author:${author}
--create time:${createTime}
--EMR Spark Streaming node can only run on exclusive resource groups.
--***************************************************--

EMR Trino

The EMR Trino code template contains the following content:

  • The --EMR Trino header line

  • The --author:${author} author variable placeholder

  • The --create time:${createTime} creation time variable placeholder

  • The note: EMR Trino nodes can only run on exclusive resource groups.

EMR Hive

The code template for EMR Hive nodes contains the template variables ${author} (author) and ${createTime} (creation time), along with the note "EMR Hive node can only run on exclusive resource groups."

EMR Spark

--EMR Spark
--*******************************************--
--author:${author}
--create time:${createTime}
--EMR Spark node can only run on exclusive resource groups.
--*******************************************--

EMR Spark SQL

The default code template for EMR Spark SQL nodes contains a comment block that defines the ${author} (author) and ${createTime} (creation time) variables, along with the note EMR Spark SQL node can only run on exclusive resource groups.

CDH

CDH Hive

--CDH Hive
--*************************************************************--
--author:${author}
--create time:${createTime}
--CDH Hive node can only run on exclusive resource groups.
--*************************************************************--

CDH Spark

--CDH Spark
--**********************************************************--
--author:${author}
--create time:${createTime}
--CDH Spark node can only run on exclusive resource groups.
--**********************************************************--

CDH MR

--CDH MR
--**********************************************************************--
--author:${author}
--create time:${createTime}
--CDH MR node can only run on exclusive resource groups.
--**********************************************************************--

CDH Presto

--CDH Presto
--**********************************************************--
--author:${author}
--create time:${createTime}
--CDH Presto node can only run on exclusive resource groups.
--**********************************************************--

CDH Impala

The CDH Impala code template contains the variables ${author} (author) and ${createTime} (creation time), along with the note that CDH Impala nodes can only run on exclusive resource groups.

Hologres

Hologres SQL

The default Hologres SQL code template contains a comment header that uses the ${author} and ${createTime} variables to automatically populate the author and creation time.

Others

Shell

#!/bin/bash
#************************************************************#
##author:${author}
##create time:${createTime}
#************************************************************#

ClickHouse SQL

Example content of the ClickHouse SQL code template: asterisk separator lines at the top and bottom, with the two template variables --author:${author} and --create time:${createTime} in between. After you edit the template, click Save.

HTTP Trigger

--HTTP Trigger
--**********************************************************--

--author:${author}
--create time:${createTime}
--HTTP Trigger is a kind of virtual node. It can trigger its child nodes when you calling the
DataWorks OpenAPI "RunTriggerNode".
--HTTP Trigger is usually used to linking with user's system
--See details here: https://www.alibabacloud.com/help/document_detail/190911.html

--**********************************************************--