In DataWorks, you can use a MariaDB node to develop tasks, schedule them to run periodically, and integrate them with other jobs. This topic describes how to develop a task by using a MariaDB node.
Background information
MariaDB is an open-source relational database management system (RDBMS) that is highly compatible with MySQL. It serves as a seamless replacement for MySQL. You can uninstall MySQL and then install MariaDB in its place without changing your application code. For more information, see MariaDB.
Prerequisites
-
A workflow is created.
You must create a workflow before you create a node. For more information, see Create a workflow.
-
A MariaDB data source has been created.
You must add your MariaDB database as a MariaDB data source in DataWorks to access its data. To create a data source, see Manage data sources. For more information about how to use MariaDB data sources in DataWorks, see MariaDB data source.
NoteMariaDB nodes support only MariaDB data sources that are created by using a JDBC connection string.
A network connection is established between your data source and a resource group.
You must make sure that the desired data source is connected to the resource group that you want to use. For more information about how to configure network connectivity, see Establish a network connection between a resource group and a data source.
-
(Optional) If you use a RAM user for task development, the RAM user must be added to the workspace and granted the Development or Workspace Administrator role. The Workspace Administrator role provides extensive permissions. Grant this role with caution. For more information about how to add members to a workspace and grant roles to the members, see Add members to a workspace.
Limits
Supported regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), China (Chengdu), China (Hong Kong), Singapore, Malaysia (Kuala Lumpur), Germany (Frankfurt), US (Silicon Valley), and US (Virginia).
Step 1: Create a MariaDB 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 target workflow and choose .
-
In the Create Node dialog box, enter a Name for the node and click OK.
Step 2: Develop a MariaDB task
(Optional) Select MariaDB data source
If your workspace has multiple MariaDB data sources, you must select the desired data source on the node editor page. If you have only one MariaDB data source, it is selected by default.
MariaDB nodes support only MariaDB data sources that are created by using a JDBC connection string.
Develop SQL code: Simple example
In the code editor of the MariaDB node, write the SQL code for your task. The following code is an example:
SELECT * FROM usertablename;
Develop SQL code: Use scheduling parameters
DataWorks provides Scheduling Parameter to dynamically pass values to your code during scheduled runs. You can define variables in your task code by using the ${variable_name} format. On the node editor page, go to the Properties tab in the right-side navigation pane, click Scheduling Parameter, and assign values to the variables. For more information about supported formats and configuration details, see Supported formats for scheduling parameters and Configure and use scheduling parameters.
The following code is an example:
SELECT '${var}'; -- Can be used with scheduling parameters.
Step 3: Configure task scheduling
If you need to run the node task periodically, click the scheduling properties tab in the right-side navigation pane of the node editor page and configure scheduling properties for the task based on your business requirements. For more information, see Overview of task scheduling properties.
Before you can commit the node, you must specify the Rerun attribute property and Parent Nodes for the node.
Step 4: Debug the task
To debug the task and check whether it runs as expected:
-
(Optional) Select a resource group for scheduling and specify values for custom parameters.
-
Click the
icon in the toolbar. In the Parameter dialog box, select the resource group for scheduling that you want to use for debugging. -
If your task code uses scheduling parameters, you can specify values for them for debugging. For more information about how to specify parameter values, see Debug a task.
-
-
Save and run the task code.
Click the
icon in the toolbar to save the task code and click the
icon to run the task. -
(Optional) Perform smoke testing.
To check if the scheduled task runs as expected in the development environment, you can perform smoke testing when you commit the node or after it is committed. For more information, see Perform smoke testing.
Step 5: Commit and deploy the task
After you configure the node task, you must commit and deploy it. Once deployed, the node runs on a schedule based on its scheduling properties.
-
Click the
icon in the toolbar to save the node. -
Click the
icon in the toolbar to commit the node task.In the Submission dialog box, enter a Change Description. You can also select whether to perform a code review after you commit the node.
Note-
Before you can commit the node, you must specify the Rerun attribute property and Parent Nodes for the node.
-
Code review helps ensure code quality and prevents task errors that may result from deploying incorrect code to the production environment without being reviewed. If you enable code review, the submitted node code can be deployed only after reviewers approve it. For more information, see Code review.
-
If you use a workspace in standard mode, you must click Deploy in the upper-right corner of the node editor page after you commit the task. This operation deploys the task to the production environment. For more information, see Deploy tasks.
What's next
After the task is published, it runs on a recurring schedule based on the node's configuration. Click O&M in the upper-right corner of the node configuration tab to go to Operation Center, where you can view the scheduling and running status of the task. For more information, see Manage recurring tasks.