AnalyticDB for MySQL 3.0 data source lets you read data from and write data to AnalyticDB for MySQL 3.0 over a bidirectional channel. This topic describes the AnalyticDB for MySQL 3.0 data synchronization capabilities supported by DataWorks.
Limits
You cannot configure or run synchronization tasks for an ADB Lakehouse Edition data source on a public resource group.
If an instance configured in an ADB data source is switched from Data Warehouse Edition to Lakehouse Edition, synchronization tasks that use this data source on a public resource group will fail. Before switching editions, check whether any tasks run on a public resource group and move them to a Serverless resource group (recommended) or an exclusive resource group for Data Integration.
Batch synchronization supports reading views (VIEW tables).
Supported field types
Batch read
The following table lists the AnalyticDB for MySQL 3.0 type mappings for AnalyticDB for MySQL 3.0 Reader.
Type category | AnalyticDB for MySQL 3.0 type |
Integer | INT, INTEGER, TINYINT, SMALLINT, and BIGINT |
Floating-point | FLOAT, DOUBLE, and DECIMAL |
String | VARCHAR |
Date and time | DATE, DATETIME, TIMESTAMP, and TIME |
Boolean | BOOLEAN |
Batch write
The following table lists the AnalyticDB for MySQL 3.0 type mappings for AnalyticDB for MySQL 3.0 Writer.
Type | AnalyticDB for MySQL 3.0 data type |
Integer | INT, INTEGER, TINYINT, SMALLINT, and BIGINT |
Floating-point | FLOAT, DOUBLE, and DECIMAL |
String | VARCHAR |
Date and time | DATE, DATETIME, TIMESTAMP, and TIME |
Boolean | BOOLEAN |
Add a data source
Before you develop a synchronization task in DataWorks, you must add the required data source to DataWorks by following the instructions in Data source configuration. You can view parameter descriptions in the DataWorks console to understand the meanings of the parameters when you add a data source.
Develop data synchronization tasks
For information about the entry point for and the procedure of configuring a synchronization task, see the following configuration guides.
Configure a single-table batch synchronization task
For the procedure, see Codeless UI configuration and Script mode configuration.
For all script mode parameters and sample scripts, see Appendix: Sample scripts and parameters.
Configure a single-table real-time synchronization task
For the procedure, see Single-table real-time synchronization task configuration.
Configure a full-database batch synchronization task
For the procedure, see Batch database synchronization configuration.
Configure a full-database real-time synchronization task
For the procedure, see Configure real-time full-database synchronization tasks.
Appendix: Sample scripts and parameters
Configure a batch synchronization task by using the code editor
If you want to configure a batch synchronization task by using the code editor, you must configure the related parameters in the script based on the unified script format requirements. For more information, see Script mode configuration. The following information describes the parameters that you must configure for data sources when you configure a batch synchronization task by using the code editor.
Reader sample script
{
"type": "job",
"steps": [
{
"stepType": "analyticdb_for_mysql", //Plug-in name.
"parameter": {
"column": [ //Column names.
"id",
"value",
"table"
],
"connection": [
{
"datasource": "xxx", //Data source.
"table": [ //Table name.
"xxx"
]
}
],
"where": "", //Filter condition.
"splitPk": "", //Split key.
"encoding": "UTF-8" //Encoding format.
},
"name": "Reader",
"category": "reader"
},
{
"stepType": "stream",
"parameter": {},
"name": "Writer",
"category": "writer"
}
],
"version": "2.0",
"order": {
"hops": [
{
"from": "Reader",
"to": "Writer"
}
]
},
"setting": {
"errorLimit": {
"record": "0" //Maximum number of error records during synchronization.
},
"speed": {
"throttle":true,//When throttle is false, mbps is ignored and throughput is unlimited; when true, throughput is limited.
"concurrent":1 //Job concurrency.
"mbps":"12"//Rate limit. Here, 1 mbps = 1 MB/s.
}
}
}Reader script parameters
Parameter | Description | Required | Default value |
datasource | The data source name. In script mode, you can add a data source. The value must match the name of the added data source. | Yes | None |
table | The table to synchronize. | Yes | None |
column | The columns to synchronize from the configured table. Describe the fields in a JSON array. By default, all columns are selected, for example, [ * ].
| Yes | None |
splitPk | When AnalyticDB for MySQL 3.0 Reader extracts data, specifying splitPk means that you want to use the field represented by splitPk to split the data. Data synchronization starts concurrent tasks to improve efficiency.
| No | None |
where | A filter condition. In many business scenarios, you synchronize the current day’s data. Setting the where condition to
| No | None |
Writer sample script
{
"type": "job",
"steps": [
{
"stepType": "stream",
"parameter": {},
"name": "Reader",
"category": "reader"
},
{
"stepType": "analyticdb_for_mysql", //Plug-in name.
"parameter": {
"postSql": [], //Statements to run after import.
"tableType": null, //Reserved field, empty by default.
"datasource": "hangzhou_ads", //Data source name.
"column": [ //Fields to synchronize.
"id",
"value"
],
"guid": null,
"writeMode": "insert", //Write mode. See the writeMode parameter description.
"batchSize": 2048, //Batch size. See the batchSize parameter description.
"encoding": "UTF-8", //Encoding format.
"table": "t5", //Name of the table to write to.
"preSql": [] //Statements to run before import.
},
"name": "Writer",
"category": "writer"
}
],
"version": "2.0", //Configuration file format version.
"order": {
"hops": [
{
"from": "Reader",
"to": "Writer"
}
]
},
"setting": {
"errorLimit": {
"record": "0" //Number of error records.
},
"speed": {
"throttle":true,//When throttle is false, mbps is ignored and throughput is unlimited; when true, throughput is limited.
"concurrent":2, //Job concurrency.
"mbps":"12"//Rate limit. Here, 1 mbps = 1 MB/s.
}
}
}Writer script parameters
Parameter | Description | Required | Default value |
datasource | The data source name. In script mode, you can add a data source. The value must match the name of the added data source. | Yes | None |
table | The name of the table to synchronize. | Yes | None |
writeMode | The write mode. Choose insert, replace, or update.
| No | insert |
column | Fields to write to the destination table, separated by commas, for example, Note If a field name contains select, enclose the field name in backticks. For example, write item_select_no as `item_select_no`. | Yes | None |
preSql | SQL statements to run before the synchronization task. Wizard mode allows only one SQL statement; script mode supports multiple statements, such as clearing old data. Note Transactions are not supported for multiple SQL statements. | No | None |
postSql | SQL statements to run after the synchronization task. Wizard mode allows only one SQL statement; script mode supports multiple statements, such as adding a timestamp. Note Transactions are not supported for multiple SQL statements. | No | None |
batchSize | The number of records submitted in one batch. This can greatly reduce network interactions between the data synchronization system and MySQL and improve overall throughput. An excessively large value can cause an out-of-memory (OOM) error in the synchronization process. | No | 1,024 |