全部產品
Search
文件中心

DataWorks:CreateDIJob - 建立Data Integration同步任務

更新時間:Apr 07, 2026

建立Data Integration新版任務。

介面說明

  • 需要購買 DataWorks 基礎版及以上版本才能使用。

  • 該介面建立了Data Integration同步任務, 參數包括同步任務的源端配置 SourceDataSourceSettings 和目的端配置 DestinationDataSourceSettings,以及支援的同步類型 MigrationType,同時通過 TransformationRules 定義了對同步表做的如加列,表名替換等映射 rule,在 TableMappings 中定義了要同步的具體表以及表需要使用的映射 rule,在 JobSettings 中定義了任務的列映射和周期設定等。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

當前API暫無授權資訊透出。

請求參數

名稱

類型

必填

描述

樣本值

DestinationDataSourceType

string

目標端資料來源類型,枚舉值:Hologres,OSS-HDFS,OSS,MaxCompute,LogHub,StarRocks,DataHub,AnalyticDB_For_MySQL,Kafka,Hive。

Hologres

Description

string

任務的描述

DI Job Demo

SourceDataSourceType

string

源端資料來源類型,枚舉值: PolarDB,MySQL,Kafka,LogHub,Hologres,Oracle,OceanBase,MongoDB,RedShift,Hive,SQLServer,Doris,ClickHouse。

MySQL

ProjectId

integer

DataWorks 工作空間的 ID。您可以登入 DataWorks 控制台,進入工作空間管理頁面擷取 ID。

該參數用來確定本次 API 呼叫操作使用的 DataWorks 工作空間。

10000

Name

string

任務名稱。

mysql_to_holo_sync_8772

MigrationType

string

同步類型,可選的枚舉值有:

  • FullAndRealtimeIncremental(全量和即時增量,整庫即時)

  • RealtimeIncremental(即時增量,單表即時)

  • Full(全量,整庫離線)

  • OfflineIncremental(離線增量,整庫離線)

  • FullAndOfflineIncremental(全量+離線增量,整庫離線)

FullAndRealtimeIncremental

JobType

string

任務類型,可選

  • DatabaseRealtimeMigration(整庫即時):將源端多個庫的多個表進行流同步,支援僅全量,僅增量,或全量+增量。

  • DatabaseOfflineMigration(整庫離線):將源端多個庫的多個表進行批同步,支援僅全量,僅增量,或全量+增量。

  • SingleTableRealtimeMigration(單表即時):將源端單個表進行流同步

DatabaseRealtimeMigration

SourceDataSourceSettings

array<object>

源端資料來源設定列表

array<object>

單個源端資料來源設定

DataSourceName

string

資料來源名稱

mysql_datasource_1

DataSourceProperties

object

資料來源屬性

Encoding

string

資料庫編碼

UTF-8

Timezone

string

時區

Asia/Shanghai

ConnectionProperties

string

與 DataSourceName 資料來源名稱二選一填寫;本參數為自訂資料來源串連配置資訊,包括執行個體 id、訪問身份、執行個體 region 等。

本參數僅支援資料來源配置為執行個體模式(ConnectionPropertiesMode),不同資料來源具有不同的屬性資訊規範,請參考資料來源串連資訊 ConnectionProperties

{ "instanceId": "rm-2ze09gn3x6xxx", "password": "xxxx", "database": "agent", "username": "zmtest" "regionId": "cn-beijing" }

DestinationDataSourceSettings

array<object>

目標端資料來源設定列表

array<object>

單個目標端資料來源設定

DataSourceName

string

資料來源名稱

holo_datasource_1

DataSourceProperties

object

資料來源屬性

ConnectionProperties

string

與 DataSourceName 資料來源名稱二選一填寫;本參數為自訂資料來源串連配置資訊,包括執行個體 id、訪問身份、執行個體 region 等。

本參數僅支援資料來源配置為執行個體模式(ConnectionPropertiesMode),不同資料來源具有不同的屬性資訊規範,請參考資料來源串連資訊 ConnectionProperties

{ "instanceId": "rm-2ze09gn3x6xxx", "password": "xxxx", "database": "agent", "username": "zmtest" "regionId": "cn-beijing" }

ResourceSettings

object

資源設定

OfflineResourceSettings

object

離線同步資源

RequestedCu

number

離線同步使用的Data Integration資源群組 cu

2

ResourceGroupIdentifier

string

離線同步使用的Data Integration資源群組名稱

S_res_group_111_222

RealtimeResourceSettings

object

即時同步資源

RequestedCu

number

即時同步使用的Data Integration資源群組 cu

2

ResourceGroupIdentifier

string

即時同步使用的Data Integration資源群組名稱

S_res_group_111_222

ScheduleResourceSettings

object

調度資源

RequestedCu

number

離線同步任務使用的調度資源群組 cu

2

ResourceGroupIdentifier

string

離線同步任務使用的調度資源群組名稱

S_res_group_222_333

TransformationRules

array<object>

同步對象轉換規則定義列表

說明

[ { "RuleName":"my_database_rename_rule", "RuleActionType":"Rename", "RuleTargetType":"Schema", "RuleExpression":"{"expression":"${srcDatasoureName}_${srcDatabaseName}"}" } ]

object

單個同步對象轉換規則定義,每個元素為一條轉換規則定義

RuleActionType

string

動作類型,可選的枚舉值:

  • DefinePrimaryKey(定義主鍵)

  • Rename(重新命名)

  • AddColumn(增加列)

  • HandleDml(DML 處理)

  • DefineIncrementalCondition(定義增量條件)

  • DefineCycleScheduleSettings(定義周期調度設定)

  • DefinePartitionKey(定義分區列)

Rename

RuleExpression

string

規則運算式,json string 格式。

  1. 重新命名規則(Rename)

  • 樣本:{"expression":"${srcDatasourceName}_${srcDatabaseName}_0922" }

  • expression:為重新命名轉換規則運算式,運算式內支援變數包括:${srcDatasourceName}(源端資料來源名)、${srcDatabaseName}(源端庫名)、${srcTableName}(源端表名)。

  1. 加列規則(AddColumn)

  • 樣本:{"columns":[{"columnName":"my_add_column","columnValueType":"Constant","columnValue":"123"}]}

  • 如不指定,預設規則為不加列不複製。

  • columnName:附加的列名稱。

  • columnValueType:附加的列取實值型別,包括 Constant(常量)、Variable(變數)。

  • columnValue:附加的列取值。當 columnValueType=Constant 時,value 為自訂常量,String 類型。當 columnValueType=Variable 時,value 為內建變數。內建變數可選值包括:EXECUTE_TIME(執行時間,Long 類型)、DB_NAME_SRC(源端資料庫名稱,String 類型)、DATASOURCE_NAME_SRC(源端資料來源名稱,String 類型)、TABLE_NAME_SRC(源端表名,String 類型)、DB_NAME_DEST(目標端資料庫名稱,String 類型)、DATASOURCE_NAME_DEST(目標端資料來源名稱,String 類型)、TABLE_NAME_DEST(目標端表名,String 類型)、DB_NAME_SRC_TRANSED(轉換後的資料庫名稱,String 類型)。

  1. 指定目標端表的主鍵列列名(DefinePrimaryKey)

  • 樣本:{"columns":["ukcolumn1","ukcolumn2"]}

  • 如不指定預設使用源端主鍵列。

  • 當目標端為已有表:Data Integration系統不會修改目標端表結構,如果指定的主鍵列不在目標端的列集合中,任務啟動會報錯提示。

  • 當目標端為自動建表:Data Integration系統會自動建立目標端表結構,表結構包含定義的主鍵列。當指定的主鍵列不在目標端的列集合中時,任務啟動會報錯提示。

  1. DML 處理規則(HandleDml)

  • 樣本: {"dmlPolicies":[{"dmlType":"Delete","dmlAction":"Filter","filterCondition":"id > 1"}]}

  • 如不指定,預設規則為 Insert、Update、Delete 均為 Normal

  • dmlType:DML 操作類型,Insert(插入)、Update(更新)、Delete(刪除)

  • dmlAction:DML 處理策略,Normal(正常處理)、Ignore(忽略)、Filter(有條件的正常處理,當 dmlType=Update/Delete 時使用)、LogicalDelete(邏輯刪除)

  • filterCondition:DML 過濾條件,當 dmlAction=Filter 時使用

  1. 增量條件(DefineIncrementalCondition)

  • 樣本: {"where":"id > 0"}

  • 指定增量過濾條件

  1. 周期調度參數(DefineCycleScheduleSettings)

  • 樣本: {"cronExpress":" * * * * * *", "cycleType":"1"}

  • 指定周期任務調度參數

  1. 指定分區鍵(DefinePartitionKey)

  • 樣本: {"columns":["id"]}

  • 指定分區鍵

{ "expression": "${srcDatasoureName}_${srcDatabaseName}" }

RuleName

string

規則名稱,當動作類型和動作作用的目標類型相同時,規則名稱需保證唯一性,長度不能超過 50 個字元

rename_rule_1

RuleTargetType

string

動作作用的目標類型,可選的枚舉值:

  • Table(表)

  • Schema(schema)

  • Database(資料庫)

Table

TableMappings

array<object>

同步對象轉換映射列表,列表中每個元素描述了一組源端同步對象選擇規則列表和在該組同步對象上應用的同步對象轉換規則列表

說明

[ { "SourceObjectSelectionRules":[ { "ObjectType":"Database", "Action":"Include", "ExpressionType":"Exact", "Expression":"biz_db" }, { "ObjectType":"Schema", "Action":"Include", "ExpressionType":"Exact", "Expression":"s1" }, { "ObjectType":"Table", "Action":"Include", "ExpressionType":"Exact", "Expression":"table1" } ], "TransformationRuleNames":[ { "RuleName":"my_database_rename_rule", "RuleActionType":"Rename", "RuleTargetType":"Schema" } ] } ]

array<object>

每條規則代表選擇需要同步的一個表

SourceObjectSelectionRules

array<object>

每條規則可選擇待同步源端對象的集合,多條規則群組成選一個表

object

每條規則可選擇待同步源端對象的不同物件類型,如選擇源端資料庫、源端資料表

Action

string

選擇動作,取值範圍:Include/Exclude

Include

Expression

string

運算式

mysql_table_1

ExpressionType

string

運算式類型,取值範圍:Exact/Regex

Exact

ObjectType

string

物件類型,可選的枚舉值:

  • Table(表)

  • Schema(schema)

  • Database(資料庫)

Table

TransformationRules

array<object>

同步對象轉換規則定義列表,列表中每個元素為一條轉換規則定義

object

源端對象上應用的轉換規則

RuleName

string

規則名稱,在一種動作類型+動作作用的目標類型下規則名稱唯一,長度不能超過 50 個字元

rename_rule_1

RuleActionType

string

動作類型,可選的枚舉值:

  • DefinePrimaryKey(定義主鍵)

  • Rename(重新命名)

  • AddColumn(增加列)

  • HandleDml(DML 處理)

  • DefineIncrementalCondition(定義增量條件)

  • DefineCycleScheduleSettings(定義周期調度設定)

  • DefinePartitionKey(定義分區列)

Rename

RuleTargetType

string

動作作用的目標類型,可選的枚舉值:

  • Table(表)

  • Schema(schema)

  • Database(資料庫)

Table

JobSettings

object

同步任務維度設定,含 DDL 處理策略、源端和目標端列資料類型映射策略、任務運行時參數等

ChannelSettings

string

通道相關任務設定,可以對一些特定通道進行特殊配置,目前支援 Holo2Holo(從 holo 同步到 holo),Holo2Kafka(從 Holo 同步到 Kafka)

  1. Holo2Kafka

  • 樣本:{"destinationChannelSettings":{"kafkaClientProperties":[{"key":"linger.ms","value":"100"}],"keyColumns":["col3"],"writeMode":"canal"}} kafkaClientProperties:kafka producer 參數,寫入 kafka 時使用

  • keyColumns, 需要寫入的 kafka 列取值

  • writeMode,kafka 寫入格式,目前支援 json/canal

  1. Holo2Holo

  • 樣本: {"destinationChannelSettings":{"conflictMode":"replace","dynamicColumnAction":"replay","writeMode":"replay"}}

  • conflictMode: 寫入 holo 衝突處理策略,replace-覆蓋、ignore-忽略

  • writeMode: 寫入 holo 方式,replay-重放、insert-插入

  • dynamicColumnAction:寫入 holo 動態列方式 replay-重放、insert-插入,ignore-忽略

{ "structInfo": "MANAGED", "storageType": "TEXTFILE", "writeMode": "APPEND", "partitionColumns": [ { "columnName": "pt", "columnType": "STRING", "comment": "" } ], "fieldDelimiter": "" }

ColumnDataTypeSettings

array<object>

列類型映射數組

說明

["ColumnDataTypeSettings":[ { "SourceDataType":"Bigint", "DestinationDataType":"Text" } ]

object

單條列類型映射

DestinationDataType

string

目標端類型。如 bigint,boolean,string,text,datetime,timestamp,decimal,binary,不同資料來源類型會有類型差異

text

SourceDataType

string

源端類型。如 bigint,boolean,string,text,datetime,timestamp,decimal,binary,不同資料來源類型會有類型差異

bigint

CycleScheduleSettings

object

周期調度設定

CycleMigrationType

string

需要周期調度的同步類型。取值範圍:

  • Full:全量

  • OfflineIncremental:離線增量

Full

ScheduleParameters

string

調度參數

bizdate=$bizdate

DdlHandlingSettings

array<object>

DDL 處理設定數組。

說明

["DDLHandlingSettings":[ { "Type":"Insert", "Action":"Normal" } ]

object

單條 DDL 處理設定

Action

string

處理動作,可選的枚舉值:

  • Ignore(忽略)

  • Critical(報錯)

  • Normal(正常處理)

Critical

Type

string

DDL 類型,可選的枚舉值:

  • RenameColumn(重新命名列)

  • ModifyColumn(重新命名列)

  • CreateTable(重新命名列)

  • TruncateTable(清空表)

  • DropTable(刪除表)

  • DropColumn(刪除列)

  • AddColumn(新增列)

AddColumn

RuntimeSettings

array<object>

運行時設定

object

Name

string

設定名稱,可選的枚舉值:

  • src.offline.datasource.max.connection(離線批量任務源端最大串連數)

  • dst.offline.truncate (是否清空目標表)

  • runtime.offline.speed.limit.enable(離線批量任務是否開啟限流)

  • runtime.offline.concurrent(離線批量同步任務並發度)

  • runtime.enable.auto.create.schema(是否自動在目標端建立 schema)

  • runtime.realtime.concurrent(即時任務並發度)

  • runtime.realtime.failover.minute.dataxcdc (failover 失敗重啟等待時間單位分鐘)

  • runtime.realtime.failover.times.dataxcdc (failover 失敗重啟次數)

runtime.offline.concurrent

Value

string

設定取值

1

JobName deprecated

string

該欄位已廢棄,請使用 Name 欄位。

mysql_to_holo_sync_8772

Owner

string

任務責任人。

3726346

FileSpec

string

指令碼模式代碼內容。

{ "resourceSettings": { "realtimeResourceSettings": { "requestedCu": 2, "resourceGroupIdentifier": "Serverless_res_group_123_456" }, "offlineResourceSettings": { "requestedCu": 2, "resourceGroupIdentifier": "Serverless_res_group_123_456" } }, "tableMappings": [ { "sourceObjectSelectionRules": [ { "expression": "autotest_hologres", "action": "Include", "expressionType": "Exact", "objectType": "Datasource" }, { "expression": "auto_holo_2661647", "action": "Include", "expressionType": "Exact", "objectType": "Table" }, { "expression": "public", "action": "Include", "expressionType": "Exact", "objectType": "Schema" } ], "transformationRules": [ { "ruleTargetType": "Table", "ruleActionType": "SourceSchema", "ruleName": "SourceSchema_Table_BStf8aXPSCJjOWGe" }, { "ruleTargetType": "Schema", "ruleActionType": "Rename", "ruleName": "Rename_Schema_3qWNOIsljtInvKJy" }, { "ruleTargetType": "Table", "ruleActionType": "Rename", "ruleName": "Rename_Table_o3PVQq1aIKDGoVVW" }, { "ruleTargetType": "Table", "ruleActionType": "DefineDstTableSettings", "ruleName": "DefineDstTableSettings_Table_BhJltOmOCIc81fzi" }, { "ruleTargetType": "Table", "ruleActionType": "ColumnMapping", "ruleName": "ColumnMapping_Table_nP4hJPX1wh2W3fpo" } ] } ], "sourceDataSourceSettings": [ { "dataSourceProperties": { "timeZone": "Asia/Shanghai" }, "dataSourceName": "autotest_hologres" } ], "jobSettings": { "runtimeSettings": [ ], "ddlHandlingSettings": [ ], "columnDataTypeSettings": [ ], "cycleScheduleSettings": { }, "channelSettings": { "destinationChannelSettings": { "conflictMode": "replace", "dynamicColumnAction": "replay", "writeMode": "replay" }, "sourceChannelSettings": { } } }, "destinationDataSourceType": "Hologres", "transformationRules": [ { "ruleTargetType": "Table", "ruleName": "SourceSchema_Table_BStf8aXPSCJjOWGe", "ruleActionType": "SourceSchema", "ruleExpression": { "columns": [ { "name": "id", "category": "normal", "type": "BIGINT" }, { "name": "decimal", "category": "normal", "type": "DECIMAL" } ] } }, { "ruleTargetType": "Schema", "ruleName": "Rename_Schema_3qWNOIsljtInvKJy", "ruleActionType": "Rename", "ruleExpression": { "expression": "public" } }, { "ruleTargetType": "Table", "ruleName": "Rename_Table_o3PVQq1aIKDGoVVW", "ruleActionType": "Rename", "ruleExpression": { "expression": "auto_holo_2661647_dst" } }, { "ruleTargetType": "Table", "ruleName": "DefineDstTableSettings_Table_BhJltOmOCIc81fzi", "ruleActionType": "DefineDstTableSettings", "ruleExpression": { "ddlString": "BEGIN; CREATE TABLE IF NOT EXISTS public.auto_holo_2661647_dst ( id BIGINT PRIMARY KEY, "decimal" DECIMAL(38,18) ); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'time_to_live_in_seconds', '3153600000'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'orientation', 'column'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'binlog.level', 'replica'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'binlog.ttl', '2592000'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'bitmap_columns', '"text","char","varchar"'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'dictionary_encoding_columns', '"text":auto,"bytea":auto,"char":auto,"varchar":auto'); CALL SET_TABLE_PROPERTY('public.auto_holo_2661647_dst', 'distribution_key', '"id"'); COMMIT; ", "ddlType": "STRUCT" } }, { "ruleTargetType": "Table", "ruleName": "ColumnMapping_Table_nP4hJPX1wh2W3fpo", "ruleActionType": "ColumnMapping", "ruleExpression": { "columnMapping": [ { "sourceColName": "id", "dstColName": "id" }, { "sourceColName": "decimal", "dstColName": "decimal" } ] } } ], "migrationType": "FullAndRealtimeIncremental", "destinationDataSourceSettings": [ { "dataSourceProperties": { }, "dataSourceName": "autotest_hologres" } ], "sourceDataSourceType": "Hologres" }

返回參數

名稱

類型

描述

樣本值

object

Schema of Response

Id

integer

Data Integration任務 ID。

11792

RequestId

string

請求的 ID。用於定位日誌,排查問題。

4F6AB6B3-41FB-5EBB-AFB2-0C98D49DA2BB

DIJobId deprecated

integer

該欄位已廢棄,請使用 Id 欄位。

11792

樣本

正常返回樣本

JSON格式

{
  "Id": 11792,
  "RequestId": "4F6AB6B3-41FB-5EBB-AFB2-0C98D49DA2BB",
  "DIJobId": 11792
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情