Accelerate code development

Updated at:
Copy as MD

DataWorks offers features such as permission verification, automatic code completion, and built-in code templates to help you write code more efficiently. You can quickly check your permissions on a table, get guided authorization, and receive intelligent code suggestions based on keywords. This topic describes how to use these features in the code editor.

Limitations

These features are supported only for ODPS SQL and script statements.

Go to the code editor

  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. Go to the code editor of a node.

    In the directory tree on the DataStudio page, find and double-click the target node to open the code editor.

Use productivity features

DataWorks provides the features described in the following table to help you write code more efficiently in the code editor.

Feature

Description

Permission verification

When you hover over a table name in a SELECT statement, DataWorks checks your permissions. If your account lacks query permissions for the table or its fields, DataWorks prompts you to apply for access in Security Center. A tooltip appears under the table name, explaining the issue and providing a link to apply for access.

Note
  • This feature checks only for query permissions on tables in the production environment. A prompt appears only if permissions are missing.

  • To request permissions on a table, see MaxCompute data access control.

Automatic code completion

  • Intelligent keyword suggestions

    As you type a keyword prefix, such as se, in the MaxCompute SQL code editor, DataWorks suggests matching keywords like SELECT, SET, and SETPROJECT. Select a suggestion to complete the keyword automatically.

  • Field completion for queries

    You can hover over a table name in your code to select the fields you want to query. DataWorks then automatically adds the selected fields to your statement. You can also hover over a field name to view its information. For example, in the ODPS SQL code editor, start with the query SELECT * FROM xc_rds_solution_0_odps_xc_dpe_e2_engine_log. Click the field selection icon next to the table name. In the pop-up list, select the fields to add, such as _before_image_ and _ddl_sql_. After you click Confirm, the query is automatically updated to SELECT *, _before_image_, _ddl_sql_ FROM xc_rds_solution_0_odps_xc_dpe_e2_engine_log.

Built-in code templates

DataWorks provides built-in code templates for common statements, such as CREATE_TABLE, SELECT_CASE, SELECT_ALL, and INSERT_OVERWRITE_TABLE. You can select a template to generate the corresponding code structure for your task.

Note

In the generated statement, TABLENAME is selected by default, so you can immediately replace it with your actual table name.

For example, if you select the SELECT_ALL template, the following code is generated in the editor.

-- ODPS SQL
--xxx
-- Author:
-- Create time: 2021-11-11 17:36:35

SELECT  *
FROM  TABLENAME
;