CreateDIJob

Updated at:

Creates a Data Integration task.

Operation description

  • You must purchase DataWorks Basic Edition or a more advanced edition to use this feature.

  • This operation creates a Data Integration synchronization task. The parameters include the source data source settings (SourceDataSourceSettings) and destination data source settings (DestinationDataSourceSettings) of the synchronization task, as well as the supported synchronization type (MigrationType). TransformationRules defines mapping rules applied to synchronized tables, such as adding columns and replacing table names. TableMappings defines the specific tables to be synchronized and the mapping rules to be applied to the tables. JobSettings defines the column mappings and cycle settings of the task.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

DestinationDataSourceType

string

No

The type of the destination data source. Valid values: Hologres, OSS-HDFS, OSS, MaxCompute, LogHub, StarRocks, DataHub, AnalyticDB_For_MySQL, Kafka, and Hive.

Hologres

Description

string

No

The description of the task.

DI Job Demo

SourceDataSourceType

string

No

The type of the source data source. Valid values: PolarDB, MySQL, Kafka, LogHub, Hologres, Oracle, OceanBase, MongoDB, RedShift, Hive, SQLServer, Doris, and ClickHouse.

MySQL

ProjectId

integer

No

The ID of the DataWorks workspace. You can log on to the DataWorks console and go to the workspace management page to obtain the ID.

This parameter is used to determine the DataWorks workspace used when you invoke this API.

10000

Name

string

No

The name of the task.

mysql_to_holo_sync_8772

MigrationType

string

No

The synchronization type. Valid values:

  • FullAndRealtimeIncremental: Full and real-time incremental synchronization, which applies to real-time synchronization of an entire database.

  • RealtimeIncremental: Real-time incremental synchronization, which applies to real-time synchronization of a single table.

  • Full: Full synchronization, which applies to offline synchronization of an entire database.

  • OfflineIncremental: Offline incremental synchronization, which applies to offline synchronization of an entire database.

  • FullAndOfflineIncremental: Full and offline incremental synchronization, which applies to offline synchronization of an entire database.

FullAndRealtimeIncremental

JobType

string

No

The task type. Valid values:

  • DatabaseRealtimeMigration: Real-time synchronization of an entire database. This type synchronizes multiple tables from multiple source databases in streaming mode. It supports full synchronization only, incremental synchronization only, or both full and incremental synchronization.

  • DatabaseOfflineMigration: Offline synchronization of an entire database. This type synchronizes multiple tables from multiple source databases in batch mode. It supports full synchronization only, incremental synchronization only, or both full and incremental synchronization.

  • SingleTableRealtimeMigration: Real-time synchronization of a single table. This type synchronizes a single source table in streaming mode.

The task type must be used in combination with the source data source type, destination data source type, and MigrationType. For example, to synchronize an entire MySQL database to Hologres in real time, set SourceDataSourceType to MySQL, DestinationDataSourceType to Hologres, JobType to DatabaseRealtimeMigration, and MigrationType to FullAndRealtimeIncremental. This configuration performs full synchronization first and then continuous incremental synchronization. For other source and destination data sources, refer to Supported data source types and read and write operations to select a synchronization scenario.

DatabaseRealtimeMigration

SourceDataSourceSettings

array<object>

No

The list of source data source settings.

array<object>

No

The settings of a single source data source.

DataSourceName

string

No

The name of the data source.

mysql_datasource_1

DataSourceProperties

object

No

The properties of the data source.

Encoding

string

No

The encoding format of the database.

UTF-8

Timezone

string

No

The time zone.

Asia/Shanghai

ConnectionProperties

string

No

Specify either this parameter or DataSourceName. This parameter specifies the custom connection configuration of the data source, including the instance ID, access identity, and instance region.

This parameter is supported only when the data source is configured in instance mode (ConnectionPropertiesMode). Different data sources have different property specifications. For more information, see Connection properties of data sources.

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

DestinationDataSourceSettings

array<object>

No

The list of destination data source settings.

array<object>

No

The settings of a single destination data source.

DataSourceName

string

No

The name of the data source.

holo_datasource_1

DataSourceProperties

object

No

The properties of the data source.

ConnectionProperties

string

No

Specify either this parameter or DataSourceName. This parameter specifies the custom connection configuration of the data source, including the instance ID, access identity, and instance region.

This parameter is supported only when the data source is configured in instance mode (ConnectionPropertiesMode). Different data sources have different property specifications. For more information, see Connection properties of data sources.

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

ResourceSettings

object

No

The resource settings of the synchronization task. This parameter is required when you configure the task by using request parameters. When you use FileSpec to create a task, specify the resource settings in the resourceSettings node of the script.

OfflineResourceSettings

object

No

The resources for offline synchronization.

RequestedCu

number

No

The number of CUs used by the Data Integration resource group for offline synchronization.

2

ResourceGroupIdentifier

string

No

The name of the Data Integration resource group used for offline synchronization.

S_res_group_111_222

RealtimeResourceSettings

object

No

The resources for real-time synchronization.

RequestedCu

number

No

The number of CUs used by the Data Integration resource group for real-time synchronization.

2

ResourceGroupIdentifier

string

No

The name of the Data Integration resource group used for real-time synchronization.

S_res_group_111_222

ScheduleResourceSettings

object

No

The scheduling resources.

RequestedCu

number

No

The number of CUs used by the scheduling resource group for the offline synchronization node.

2

ResourceGroupIdentifier

string

No

The name of the scheduling resource group used for the offline synchronization node.

S_res_group_222_333

TransformationRules

array<object>

No

The list of transformation rule definitions for synchronization objects.

Note

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

object

No

A single transformation rule definition for a synchronization object. Each element represents a transformation rule definition.

RuleActionType

string

No

The action type. Valid values:

  • DefinePrimaryKey: Defines the primary key.

  • Rename: Renames the object.

  • AddColumn: Adds a column.

  • HandleDml: Processes DML operations.

  • DefineIncrementalCondition: Defines the incremental condition.

  • DefineCycleScheduleSettings: Defines the cycle scheduling settings.

  • DefinePartitionKey: Defines the partition key.

Rename

RuleExpression

string

No

The rule expression in JSON string format.

  1. Rename rule (Rename)

  • Example: {"expression":"${srcDatasourceName}_${srcDatabaseName}_0922" }

  • expression: the expression for the rename transformation rule. Supported variables in the expression include: ${srcDatasourceName} (source data source name), ${srcDatabaseName} (source database name), and ${srcTableName} (source table name).

  1. Add column rule (AddColumn)

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

  • If not specified, the default rule is to add no columns and perform no replication.

  • columnName: the name of the added column.

  • columnValueType: the value type of the added column. Valid values: Constant and Variable.

  • columnValue: the value of the added column. When columnValueType is set to Constant, the value is a custom constant of the String type. When columnValueType is set to Variable, the value is a built-in variable. Valid built-in variables include: EXECUTE_TIME (execution time, Long type), DB_NAME_SRC (source database name, String type), DATASOURCE_NAME_SRC (source data source name, String type), TABLE_NAME_SRC (source table name, String type), DB_NAME_DEST (destination database name, String type), DATASOURCE_NAME_DEST (destination data source name, String type), TABLE_NAME_DEST (destination table name, String type), and DB_NAME_SRC_TRANSED (transformed database name, String type).

  1. Specify the primary key column names of the destination table (DefinePrimaryKey)

  • Example: {"columns":["ukcolumn1","ukcolumn2"]}

  • If not specified, the primary key columns of the source table are used by default.

  • When the destination is an existing table: the Data Integration system does not modify the table schema structure of the destination table. If the specified primary key columns are not in the column set of the destination table, an error is reported when the node starts.

  • When the destination is an automatic creation table: the Data Integration system performs automatic creation of the table schema structure of the destination table, and the table schema structure includes the defined primary key columns. If the specified primary key columns are not in the column set of the destination table, an error is reported when the node starts.

  1. DML processing rule (HandleDml)

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

  • If not specified, the default rule is Normal for Insert, Update, and Delete operations.

  • dmlType: the DML operations type. Valid values: Insert, Update, and Delete.

  • dmlAction: the DML processing policy. Valid values: Normal (normal processing), Ignore (ignore), Filter (conditional normal processing, used when dmlType is Update or Delete), and LogicalDelete (logical deletion).

  • filterCondition: the DML filter condition, used when dmlAction is set to Filter.

  1. Incremental condition (DefineIncrementalCondition)

  • Example: {"where":"id > 0"}

  • Specifies the incremental filter condition.

  1. Periodic scheduling parameters (DefineCycleScheduleSettings)

  • Example: {"cronExpress":" * * * * * *", "cycleType":"1"}

  • Specifies the scheduling parameters for the scheduled task.

  1. Specify the partition key (DefinePartitionKey)

  • Example: {"columns":["id"]}

  • Specifies the partition key.

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

RuleName

string

No

The name of the rule. When the action type and the target type of the action are the same, the rule name must be unique and cannot exceed 50 characters in length.

rename_rule_1

RuleTargetType

string

No

The target type of the action. Valid values:

  • Table: table

  • Schema: schema

  • Database: database

Table

TableMappings

array<object>

No

The list of transformation mappings for synchronization objects. Each element in the list describes a set of source object selection rules and a list of transformation rules applied to the selected synchronization objects.

Note

[ { "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>

No

Each rule represents a table selected for synchronization.

SourceObjectSelectionRules

array<object>

No

Each rule selects a set of source objects to be synchronized. Multiple rules combine to select a single table.

object

No

Each rule can select different object types of the source objects to be synchronized, such as source databases and source tables.

Action

string

No

The selection action. Valid values: Include and Exclude.

Include

Expression

string

No

The expression.

mysql_table_1

ExpressionType

string

No

The expression type. Valid values: Exact and Regex.

Exact

ObjectType

string

No

The object type. Valid values:

  • Table: table

  • Schema: schema

  • Database: database

Table

TransformationRules

array<object>

No

The list of transformation rule definitions for synchronization objects. Each element in the list represents a transformation rule definition.

object

No

The transformation rule applied to the source object.

RuleName

string

No

The name of the rule. The rule name must be unique under a specific combination of action type and target type, and cannot exceed 50 characters in length.

rename_rule_1

RuleActionType

string

No

The action type. Valid values:

  • DefinePrimaryKey: Defines the primary key.

  • Rename: Renames the object.

  • AddColumn: Adds a column.

  • HandleDml: Processes DML operations.

  • DefineIncrementalCondition: Defines the incremental condition.

  • DefineCycleScheduleSettings: Defines the cycle scheduling settings.

  • DefinePartitionKey: Defines the partition key.

Rename

RuleTargetType

string

No

The target type of the action. Valid values:

  • Table: table

  • Schema: schema

  • Database: database

Table

JobSettings

object

No

The settings at the synchronization task level, including DDL processing policies, column data type mapping policies between the source and destination, and task runtime parameters.

ChannelSettings

string

No

The channel-related task settings. You can configure specific channels. Currently, Holo2Holo (synchronization from Hologres to Hologres) and Holo2Kafka (synchronization from Hologres to Kafka) are supported.

  1. Holo2Kafka

  • Example: {"destinationChannelSettings":{"kafkaClientProperties":[{"key":"linger.ms","value":"100"}],"keyColumns":["col3"],"writeMode":"canal"}}

  • kafkaClientProperties: the Kafka producer parameters used when writing to Kafka.

  • keyColumns: the Kafka columns whose values need to be written.

  • writeMode: the Kafka write format. Valid values: json and canal.

  1. Holo2Holo

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

  • conflictMode: the conflict processing policy when writing to Hologres. Valid values: replace (overwrite) and ignore (ignore).

  • writeMode: the method to write to Hologres. Valid values: replay (replay) and insert (insert).

  • dynamicColumnAction: the method to write dynamic columns to Hologres. Valid values: replay (replay), insert (insert), and ignore (ignore).

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

ColumnDataTypeSettings

array<object>

No

The array of column data type mappings.

Note

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

object

No

A single column data type mapping.

DestinationDataType

string

No

The destination data type, such as bigint, boolean, string, text, datetime, timestamp, decimal, or binary. Data types vary based on the data source type.

text

SourceDataType

string

No

The source data type, such as bigint, boolean, string, text, datetime, timestamp, decimal, or binary. Data types vary based on the data source type.

bigint

CycleScheduleSettings

object

No

The cycle scheduling settings.

CycleMigrationType

string

No

The synchronization type that requires cycle scheduling. Valid values:

  • Full: Full synchronization.

  • OfflineIncremental: Offline incremental synchronization.

Full

ScheduleParameters

string

No

The scheduling parameters.

bizdate=$bizdate

DdlHandlingSettings

array<object>

No

The array of DDL processing settings.

Note

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

object

No

A single DDL processing setting.

Action

string

No

The processing action. Valid values:

  • Ignore: Ignores the DDL operation.

  • Critical: Reports an error.

  • Normal: Processes the DDL operation normally.

Critical

Type

string

No

The DDL type. Valid values:

  • RenameColumn: Renames a column.

  • ModifyColumn: Modifies a column.

  • CreateTable: Creates a table.

  • TruncateTable: Truncates a table.

  • DropTable: Drops a table.

  • DropColumn: Drops a column.

  • AddColumn: Adds a column.

AddColumn

RuntimeSettings

array<object>

No

The runtime settings.

object

No

Name

string

No

The setting name. Valid values:

  • src.offline.datasource.max.connection: The maximum number of connections to the source for offline batch tasks.

  • dst.offline.truncate: Specifies whether to truncate the destination table.

  • runtime.offline.speed.limit.enable: Specifies whether to enable throttling for offline batch tasks.

  • runtime.offline.concurrent: The concurrency of offline batch synchronization tasks.

  • runtime.enable.auto.create.schema: Specifies whether to automatically create a schema at the destination.

  • runtime.realtime.concurrent: The concurrency of real-time tasks.

  • runtime.realtime.failover.minute.dataxcdc: The wait time in minutes for failover restart.

  • runtime.realtime.failover.times.dataxcdc: The number of failover restart attempts.

runtime.offline.concurrent

Value

string

No

The setting value.

1

JobName deprecated

string

No

[Deprecated] Use the Name parameter instead.

mysql_to_holo_sync_8772

Owner

string

No

The owner of the task.

3726346

FileSpec

string

No

The code content in script mode.

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

Response elements

Element

Type

Description

Example

object

Schema of Response

Id

integer

The ID of the Data Integration task.

11792

RequestId

string

The ID of the request. You can use the ID to locate logs and troubleshoot issues.

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

DIJobId deprecated

integer

[Deprecated] Use the Id parameter instead.

11792

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.