全部產品
Search
文件中心

DataWorks:CreateDIJob

更新時間:Sep 03, 2026

建立資料整合新版任務。

介面說明

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

  • 該介面建立了資料整合同步任務, 參數包括同步任務的來源端設定 SourceDataSourceSettings 和目的端設定 DestinationDataSourceSettings,以及支援的同步類型 MigrationType,同時透過 TransformationRules 定義了對同步表所做的如新增欄位、表名替換等對應規則,在 TableMappings 中定義了要同步的具體表以及表需要使用的對應規則,在 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

否

離線同步使用的資料整合資源群組 CU。

2

ResourceGroupIdentifier

string

否

離線同步使用的資料整合資源群組名稱。

S_res_group_111_222

RealtimeResourceSettings

object

否

即時同步資源。

RequestedCu

number

否

即時同步使用的資料整合資源群組 CU。

2

ResourceGroupIdentifier

string

否

即時同步使用的資料整合資源群組名稱。

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 字串格式。

  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"]}

  • 如不指定,預設使用來源端主鍵欄位。

  • 當目標端為既有表:資料整合系統不會修改目標端表結構,如果指定的主鍵欄位不在目標端的欄位集合中,任務啟動會報錯提示。

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

  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

資料整合任務 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
}

錯誤碼

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

變更歷史

更多資訊,參考變更詳情。