This topic describes how to migrate data from MaxCompute to Tablestore using the data integration and development features of DataWorks.
Procedure
Activate services
Create a table in DataWorks
Log on to the DataWorks console and select a region in the upper-left corner.
In the left navigation pane, click Workspace.
On the Workspaces page, find the target workspace and in the Actions column, choose .
On the Data Studio page, create a MaxCompute SQL node. Then, run the following statement to create a table named
transs.CREATE TABLE transs (name STRING, id STRING, gender STRING);
Import data into the
transstableSave the following sample data to your computer as a
CSVfile.qwe,145,F asd,256,F xzc,345,M rgth,234,F ert,456,F dfg,12,M tyj,4,M bfg,245,M nrtjeryj,15,F rwh,2344,M trh,387,F srjeyj,67,M saerh,567,MIn the left navigation pane, choose .
Click Go to Data Upload and Download.
In the left navigation pane, click the upload icon
and then click Upload Data.
Create a table in the Tablestore console
Log on to the Tablestore console and create an instance.
Create a data table named trans. For more information, see Create a data table.
Set the primary keys to name and id.
Add a MaxCompute data source in DataWorks
Log on to the DataWorks console and select a region in the upper-left corner.
In the left navigation pane, click Workspace.
On the Workspaces page, click the name of the target workspace.
On the Workspace Details page, click Data Sources in the left navigation pane.
On the Data Source tab, click Add Data Source, and select MaxCompute.
On the Add MaxCompute Data Source page, configure the Basic Information.
For more information, see Configure a MaxCompute data source.
Add a Tablestore data source. For more information, see Configure a Tablestore data source.
Configure the MaxCompute (ODPS) Reader and the Tablestore (OTS) Writer
Log on to the DataWorks console and select a region in the upper-left corner.
In the left navigation pane, choose .
In the Select Workspace section, click Go to Data Studio.
In the left pane of Data Studio, click the
icon and select .Select Tablestore as the data source.
For Data Destination, select MaxCompute (ODPS).
On the node configuration page, configure the following parameters.
Data Source-Source: Select the MaxCompute data source that you added.
Data Source-Destination: Select the Tablestore data source that you added.
Data Source > Table: Select an existing table in OTS.
Destination-Table: Select the Tablestore table that you created.
Runtime Resource: Select the exclusive resource group that you created.
Keep the default values for the other parameters.
Alternatively, you can click the
icon above the configuration section to switch to the code editor and configure the node using a script. The following code provides an example:{ "type": "job", "steps": [ { "stepType": "odps", "parameter": { "partition": [], "datasource": "odps_first", "column": [ "name", "id", "gender" ], "table": "transs" }, "name": "Reader", "category": "reader" }, { "stepType": "ots", "parameter": { "datasource": "transs", "column": [ { "name": "gender", "type": "STRING" } ], "writeMode": "UpdateRow", "table": "trans", "primaryKey": [ { "name": "name", "type": "STRING" }, { "name": "id", "type": "INT" } ] }, "name": "Writer", "category": "writer" } ], "version": "2.0", "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] }, "setting": { "errorLimit": { "record": "0" }, "speed": { "throttle": false, "concurrent": 1, "dmu": 1 } } }
View the data in the Tablestore console.
Log on to the Tablestore console. In the upper-left corner, select a region.
In the navigation pane on the left, select All Instances.
On the All Instances page, click the instance name to go to the Instance Management page.
On the Instance Management page, click the Instance Details tab.
On the Instance Details tab, in the Tables area, click the name of the data table that you want to view.
On the data table management page, click the Query Data tab to view the data in the table.