You can use AnalyticDB for MySQL nodes in DataWorks to develop tasks, run them periodically, and integrate them with other jobs. This topic describes how to develop a task using an AnalyticDB for MySQL node.
Prerequisites
-
An AnalyticDB for MySQL cluster has been purchased. For more information, see Create a cluster.
-
A workflow has been created.
In DataStudio, workflows organize development operations for different engines. Therefore, you must create a workflow before you create a node. For more information, see Create a workflow.
-
An AnalyticDB for MySQL (V3.0) computing resource has been bound to DataStudio.
To access data and perform development in your AnalyticDB for MySQL database, you must add it as an AnalyticDB for MySQL computing resource to DataWorks and then bind the resource to DataStudio.
-
A serverless resource group (recommended) or an exclusive resource group for scheduling has been purchased.
Background information
AnalyticDB for MySQL is an analytical database service provided by Alibaba Cloud. For more information, see What is AnalyticDB for MySQL?
Step 1: Create an AnalyticDB for MySQL node
Go to the DataStudio page.
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.
-
Right-click the workflow and choose .
-
In the Create Node dialog box, enter a Name for the node and click OK. The node's configuration tab opens, where you can develop and configure the task.
Step 2: Develop an AnalyticDB for MySQL task
Select a computing resource (optional)
If your workspace has multiple AnalyticDB for MySQL computing resources, select the one you want to use on the node configuration tab. If only one is available, it is used by default.
Develop SQL code
In the code editor of the AnalyticDB for MySQL node, write the SQL code for the task. The following code is an example:
SHOW TABLES;
Step 3: Configure task scheduling
To run the task on a schedule, click Scheduling in the right-side pane of the node configuration tab to configure its scheduling properties. For more information about the configurations, see Configure scheduling properties for a node.
You must set the Rerun attribute and Parent Nodes properties for the node before you commit it.
Step 4: Debug the task code
Follow these steps to debug the code and verify that the task runs as expected.
-
(Optional) Select a resource group for running the task and assign values to custom parameters.
-
Click the
icon in the toolbar. In the Parameter dialog box, select the resource group to use for debugging. -
If your code uses scheduling parameters, assign values to them for debugging. For more information about the value assignment logic, see Debug an auto-triggered node.
-
-
Save and run the SQL statements.
Click the
icon in the toolbar to save the SQL statements, and then click the
icon to run the SQL task. -
(Optional) Perform smoke testing.
To verify that the scheduled task runs as expected in the development environment, you can perform smoke testing when you commit the node or anytime after. For more information, see Perform smoke testing.
Step 5: Commit and deploy the task
After you configure the node task, commit and deploy it. Once deployed, the task runs periodically based on its scheduling properties.
-
Click the
icon in the toolbar to save the task. -
Click the
icon in the toolbar to commit the task.In the Submission dialog box, enter a Change Description of the change. You can also specify whether to perform code review after the task is committed.
Note-
Before committing the task, you must set the node's Rerun attribute and Parent Nodes properties.
-
Code review ensures code quality and prevents the deployment of faulty code to the production environment. If you enable code review, a reviewer must approve the committed code before it can be deployed. For more information, see Code review.
-
If your workspace is in standard mode, after committing the task, click Deploy in the upper-right corner of the node configuration tab to deploy it to the production environment. For more information, see Deploy tasks.
Next steps
After a task is deployed, it runs according to its schedule. To view the run status, click O&M Personnel in the upper-right corner of the node configuration tab. For more information, see View and manage auto-triggered tasks.