This topic describes how to use the data synchronization feature of DataWorks to migrate data from MaxCompute to Object Storage Service (OSS).
Prerequisites
Create a DataWorks on the workflow. This example uses DataWorks simple mode. For more information, see create a workflow.
Procedure
Create a table in the DataWorks console.
Login DataWorks console.
In the left-side navigation pane, click Workspaces.
On the Workspaces page, find the workspace that you want to configure and click Data Development in the Actions column.
Right-click a created workflow, Select .
In create a table page, select the engine type, and enter table name.
On the table editing page, click DDL Statement.
In the DDL dialog box, enter the following CREATE TABLE statement and click Generate Table Schema.
create table Transs (name string, id string, gender string);
Click Submit to Production Environment.
Import data to the table Transs.
Click on the DataStudio page.
In data import wizard dialog box that appears, enter at least three letters to search for the table to which data is to be imported, and then click next Step.
In the dialog box that appears, set Select Data Import Method to Upload Local File and click Browse next to Select File. Select the local file that you want to import and specify other parameters.
Example:
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,M
Click Next.
Select how destination table fields match the source fields.
Click Import Data.
Create a table in the OSS console.
Log on to the OSS console and create a bucket. For more information, see Create buckets.
Upload the file qwee.csv to OSS. For more information, see Upload objects.
NoteMake sure that fields in the file qwee.csv are exactly the same as the fields in the Transs table.
Add data sources in the DataWorks console.
Login DataWorks console.
In the left-side navigation pane, click Workspaces.
On the Workspaces page that appears, find the target workspace and click Data Integration in the Actions column.
In the left-side navigation pane of the Data Integration page, click Data Source to go to the Data Sources page.
On the Data Sources page, click Create Data Source. In the Add data source dialog box, click MaxCompute.
In the Add MaxCompute data source dialog box, configure the parameters and click Complete. For more information, see Add a MaxCompute data source.
Add OSS as a data source. For more information, see Add an OSS data source.
Configure MaxCompute as the reader and OSS as the writer.
Go to the data analytics page. Right-click the specified workflow and choose .
In create a node dialog box, enter node name, and click submit.
In the top navigation bar, choose icon.
In script mode, click icon.
In import Template dialog box SOURCE type, data source, target type and data source, and click confirm.
Modify JSON code and click the icon.
Sample code:
{ "order":{ "hops":[ { "from":"Reader", "to":"Writer" } ] }, "setting":{ "errorLimit":{ "record":"0" }, "speed":{ "concurrent":1, "dmu":1, "throttle":false } }, "steps":[ { "category":"reader", "name":"Reader", "parameter":{ "column":[ "name", "id", "gender" ], "datasource":"odps_first", "partition":[], "table":"Transs" }, "stepType":"odps" }, { "category":"writer", "name":"Writer", "parameter":{ "datasource":"Trans", "dateFormat":"yyyy-MM-dd HH:mm:ss", "encoding":"UTF-8", "fieldDelimiter":",", "fileFormat":"csv", "nullFormat":"null", "object":"qweee.csv", "writeMode":"truncate" }, "stepType":"oss" } ], "type":"job", "version":"2.0" }
View the data of the newly created table in the OSS console. For more information, see Download objects.