Updated on 2025-12-15 GMT+08:00

Creating a Comparison Task

Function

This API is used to create a comparison task

Debugging

You can debug the API in API Explorer to support automatic authentication. API Explorer can automatically generate and debug example SDK code.

Constraints

In the current version, a comparison task can be created only when the task is in the INCRE_TRANSFER_STARTED state. The parent task cannot call the API.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions and Supported Actions.

URI

POST /v3/{project_id}/jobs/create-compare-task

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region

For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

The content type.

The default value is application/json.

X-Auth-Token

Yes

String

User token obtained from IAM.

X-Language

No

String

Request language type

Default value: en-us

Values:

  • en-us
  • zh-cn
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

job_id

Yes

String

Task ID.

object_level_compare_type

No

String

Object-level comparison type. If the value is empty, the object-level comparison is not created. If both object_level_compare_type and data_level_compare_info are left empty, only the created comparison task list is queried.

Value: objects

data_level_compare_info

No

Object

Data-level comparison information. If no data-level comparison is created, this parameter does not need to be transferred. If both object_level_compare_type and data_level_compare_info are left empty, only the created comparison task list is queried.

For details, see Table 4.

Table 4 Data structure description of field data_level_compare_info

Parameter

Mandatory

Type

Description

conflict_policy

Yes

String

Only one unfinished data-level comparison task can exist. This field determines how to process unfinished data-level comparison tasks. cancel: Cancel the unfinished task and create a new one. keep: Retain the unfinished task.

Values:

  • cancel
  • keep

compare_type

Yes

String

Data-level comparison type. lines: indicates row comparison. contents: indicates value comparison.

Values:

  • lines
  • contents
    NOTE:

    Object-level comparison and value comparison cannot be performed at the same time.

compare_mode

No

String

Data-level comparison mode. If the value is empty, the object information needs to be transferred in compare_object_infos or compare_object_infos_with_token. quick_comparison: indicates quick comparison, which can be used only by whitelisted users.

Default value: quick_comparison

Value: quick_comparison

start_time

No

String

Start time of a comparison task. If the value is empty, the task is started immediately.

compare_object_infos

No

Array of objects

Data-level comparison object. In non-quick comparison mode, either compare_object_infos or compare_object_infos_with_token must be specified based on the migration scenario.

For details, see Table 5.

compare_object_infos_with_token

No

Array of objects

Object for data-level comparison (Cassandra DR only, with token information). In non-quick comparison mode, either compare_object_infos or compare_object_infos_with_token must be specified based on the migration scenario.

For details, see Table 6.

Table 5 Data structure description of field compare_object_infos

Parameter

Mandatory

Type

Description

db_name

Yes

String

Database name.

table_name

No

Array of strings

List of table names in the database.

Table 6 Data structure description of field compare_object_infos_with_token

Parameter

Mandatory

Type

Description

db_name

Yes

String

Database name.

table_name_with_token

No

Array of objects

List of tables (with tokens) in the database.

For details, see Table 7.

Table 7 Data structure description of field table_name_with_token

Parameter

Mandatory

Type

Description

table_name

Yes

String

Table name

min_token

No

String

Min token of a table.

max_token

No

String

Max token of a table.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

job_id

String

Task ID

object_level_compare_create_result

Object

Result of creating an object-level comparison task.

For details, see Table 9.

data_level_compare_create_result

Object

Result of creating a data-level comparison task.

For details, see Table 9.

error_code

String

Error code.

error_msg

String

Error message.

Table 9 Data structure description of fields object_level_compare_create_result and data_level_compare_create_result

Parameter

Type

Description

compare_task_id

String

After the comparison task is created, the ID of the comparison task is returned for querying the result of the comparison task.

error_code

String

Error code.

error_msg

String

Error message.

Example Request

Creating object-level comparison and data-level row comparison tasks

https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/create-compare-task

{
  "job_id" : "94800607-3cd8-4f7d-a340-63a10f8jb502",
  "object_level_compare_type" : "objects",
  "data_level_compare_info" : {
    "conflict_policy" : "keep",
    "compare_type" : "lines",
    "compare_mode" : null,
    "start_time" : null,
    "compare_object_infos" : [ {
      "db_name" : "may_5",
      "table_name" : [ "table_name_0", "table_name_1" ]
    } ]
  }
}

Example Response

Status code: 200

OK

{
  "job_id" : "94800607-3cd8-4f7d-a340-63a10f8jb502",
  "object_level_compare_create_result" : {
    "compare_task_id" : "dc1683d9-bdf2-4be9-967f-6ef0953369bc"
  },
  "data_level_compare_create_result" : {
    "compare_task_id" : "08cad1f8-9de2-42fa-b8ce-6c36daf730f6"
  }
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.