DataWorks provides AnalyticDB for MySQL nodes that you can use to develop and periodically schedule AnalyticDB for MySQL tasks and integrate AnalyticDB for MySQL tasks with other types of tasks. This topic describes how to use an AnalyticDB for MySQL node to develop tasks.
Prerequisites
An AnalyticDB for MySQL cluster is created. For more information, see Create a cluster.
A workflow is created.
DataStudio allows you to perform development operations for different types of compute engines based on workflows. Therefore, you must create a workflow before you create a node. For more information, see Create a workflow.
An AnalyticDB for MySQL data source is added and associated with DataStudio.
You must add an AnalyticDB for MySQL database to DataWorks as an AnalyticDB for MySQL data source and associate the data source with DataStudio before you can use the data source to access AnalyticDB for MySQL data and perform subsequent development operations. For more information, see Add an AnalyticDB for MySQL 3.0 data source and Preparations before data development: Associate a data source or a cluster with DataStudio.
A serverless resource group (recommended) or an exclusive resource group for scheduling is purchased.
Background Information
AnalyticDB for MySQL is an analytical database of 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.
Find the desired workflow, right-click the workflow name, and then choose
.In the Create Node dialog box, configure the Name parameter and click Confirm. Then, you can use the node to develop tasks and configure task scheduling properties.
Step 2: Develop an AnalyticDB for MySQL task
(Optional) Select an AnalyticDB for MySQL data source
If you have added multiple AnalyticDB for MySQL data sources to the desired workspace, you must select a data source on the configuration tab of the AnalyticDB for MySQL node before you can use the node to develop tasks. If you have added only one AnalyticDB for MySQL data source to the desired workspace, the data source is used to develop tasks by default.
Develop SQL code
In the code editor on the configuration tab of the AnalyticDB for MySQL node, write task code. Sample task code:
show tables;
Step 3: Configure scheduling properties for the AnalyticDB for PostgreSQL task
If you want the system to periodically run a task on the node, you can click Properties in the right-side navigation pane on the configuration tab of the node to configure task scheduling properties based on your business requirements. For more information, see Overview.
You must configure the Rerun and Parent Nodes parameters on the Properties tab before you commit the task.
Step 4: Debug the task code
You can perform the following operations to check whether the task is configured as expected based on your business requirements:
Optional. Select a resource group and assign custom parameters to variables.
Click the icon in the top toolbar of the configuration tab of the node. In the Parameters dialog box, select a resource group for scheduling that you want to use to debug and run task code.
If you use scheduling parameters in your task code, assign the scheduling parameters to variables as values in the task code for debugging. For more information about the value assignment logic of scheduling parameters, see Debugging procedure.
Save and execute SQL statements.
In the top toolbar, click the icon to save SQL statements. Then, click the icon to execute the SQL statements.
Optional. Perform smoke testing.
You can perform smoke testing on the node in the development environment when you commit the node or after you commit the node. For more information, see Perform smoke testing.
Step 5: Commit and deploy the task
After you configure the task on the node, you must commit and deploy the task. The task can be periodically run based on the scheduling configurations after you commit and deploy the task.
Click the icon in the top toolbar to save the task.
Click the icon in the top toolbar to commit the task.
In the Submit dialog box, configure the Change description parameter. Then, determine whether to review task code after you commit the task based on your business requirements.
NoteYou must configure the Rerun and Parent Nodes parameters on the Properties tab before you commit the task.
You can use the code review feature to ensure the code quality of tasks and prevent task execution errors caused by invalid task code. If you enable the code review feature, the task code that is committed can be deployed only after the task code passes the code review. For more information, see Code review.
If you use a workspace in standard mode, you must deploy the node in the production environment after you commit the node. To deploy a node, click Deploy in the upper-right corner of the configuration tab of the node. For more information, see Deploy nodes.
What to do next
After you commit and deploy the task, the task is periodically run based on the scheduling configurations. You can click Operation Center in the upper-right corner of the configuration tab of the corresponding node to go to Operation Center and view the scheduling status of the task. For more information, see View and manage auto triggered nodes.