Querying Comparison Results

Function

This API is used to query the comparion result after creating a comparison task.

URI

POST /v3/{project_id}/jobs/query-compare-result

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

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_id

No

String

ID of the object-level comparison task that requests the query result. The value can be obtained from the returned parameters in Creating a Comparison Task.

line_compare_id

No

String

ID of the row comparison task that requests the query result. The value can be obtained from the returned parameters in Creating a Comparison Task.

content_compare_id

No

String

ID of the value comparison task that requests the query result. The value can be obtained from the returned parameters in Creating a Comparison Task.

current_page

Yes

Integer

Current page number for pagination query, which is valid for the query result of comparison tasks.

per_page

Yes

Integer

Number of records on each page. This parameter is valid only for query results of comparison tasks.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

job_id

String

Task ID

object_level_compare_results

ObjectCompareResult object

Object-level comparison result.

line_compare_results

LineCompareResult object

Row comparison result.

content_compare_results

ContentCompareResult object

Value comparison result.

compare_task_list_results

CompareTaskListResult object

List of comparison tasks.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Table 5 ObjectCompareResult

Parameter

Type

Description

compare_task_id

String

ID of an object-level comparison task.

object_compare_overview

Array of ObjectCompareResultOverview objects

Overview of object comparison results.

object_compare_details

Array of ObjectCompareResultDetails objects

Object comparison result details. The key value is the object type in the object comparison result overview.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Table 6 ObjectCompareResultOverview

Parameter

Type

Description

object_type

String

Object type.

Values:

  • DB-database

  • TABLE-table

  • VIEW-view

  • EVENT-event

  • ROUTINE - stored procedure and function

  • INDEX: index

  • TRIGGER: trigger

  • SYNONYM - synonym

  • FUNCTION-function

  • PROCEDURE: stored procedure

  • TYPE: user-defined type

  • RULE-rule

  • DEFAULT_TYPE: default value

  • PLAN_GUIDE-execution plan

  • CONSTRAINT-constraint

  • FILE_GROUP-file group

  • PARTITION_FUNCTION-partition function

  • PARTITION_SCHEME-partition scheme

  • TABLE_COLLATION-table sorting rule

  • EXTENSIONS - Plugin

object_compare_result

String

Comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

target_count

Integer

Number of objects of this type in the destination database.

source_count

Integer

Number of objects of this type in the source database.

diff_count

Integer

Number of differences between the source and destination databases.

Table 7 ObjectCompareResultDetails

Parameter

Type

Description

source_db_name

String

Source database name.

target_db_name

String

Destination database name.

source_db_value

String

Value in the source database.

target_db_value

String

Value in the destination database.

error_message

String

Error message.

Table 8 LineCompareResult

Parameter

Type

Description

compare_task_id

String

ID of a row comparison task.

line_compare_overview

Array of LineCompareResultOverview objects

Row comparison result overview.

line_compare_overview_count

Integer

Row comparison result overview.

line_compare_details

Array of LineCompareResultDetails objects

Row comparison result details.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Table 9 LineCompareResultOverview

Parameter

Type

Description

source_db_name

String

Source database name.

target_db_name

String

Destination database name.

line_compare_result

String

Comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

Table 10 LineCompareResultDetails

Parameter

Type

Description

source_db_name

String

Source database name.

LineCompareDetail

Array of LineCompareDetail objects

Row comparison details of the tables in the database.

line_compare_detail_count

Integer

Total number of row comparison results in the database.

Table 11 LineCompareDetail

Parameter

Type

Description

source_table_name

String

Table name of the source database.

target_table_name

String

Table name of the destination database.

source_row_num

Integer

Number of table rows in the source database.

target_row_num

Integer

Number of table rows in the destination database.

diff_row_num

Integer

Difference between the tables in the source and destination databases.

line_compare_result

String

Comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

message

String

Additional information.

Table 12 ContentCompareResult

Parameter

Type

Description

compare_task_id

String

ID of a value comparison task.

content_compare_overview

Array of ContentCompareResultOverview objects

Content comparison result overview.

content_compare_overview_count

Integer

Total number of value comparison results.

content_compare_details

Array of ContentCompareResultDetails objects

Value comparison result details.

content_compare_diffs

Array of ContentCompareResultDiffs objects

The value comparison results are different.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Table 13 ContentCompareResultOverview

Parameter

Type

Description

source_db_name

String

Source database name.

target_db_name

String

Destination database name.

content_compare_result

String

Comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

Table 14 ContentCompareResultDetails

Parameter

Type

Description

source_db_name

String

Source database name.

content_compare_detail

Array of ContentCompareDetail objects

Value comparison details of the tables in the database.

content_compare_detail_count

Integer

Total number of value comparison results.

content_uncompare_detail

Array of ContentCompareDetail objects

Value comparison details of tables in the database (tables that cannot be compared).

content_uncompare_detail_count

Integer

Total number of value comparison results (tables that cannot be compared).

Table 15 ContentCompareDetail

Parameter

Type

Description

source_db_name

String

Source database name.

target_db_name

String

Destination database name.

source_table_name

String

Source database name.

target_table_name

String

Name of a table in the destination database.

source_row_num

Integer

Number of rows in the table of the source database.

target_row_num

Integer

Number of rows in the table of the destination database.

diff_row_num

Integer

Difference between the tables in the source and destination databases.

line_compare_result

String

Row comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

content_compare_result

String

Value comparison result.

Values:

  • CONSISTENT: consistent

  • INCONSISTENT: inconsistent

  • COMPARING: The comparison is in progress

  • WAITING_FOR_COMPARISON: waiting for comparison

  • FAILED_TO_COMPARE: comparison failure

  • TARGET_DB_NOT_EXIT-Destination database does not exist

  • CAN_NOT_COMPARE-Cannot be compared

message

String

Provides additional information.

Table 16 ContentCompareResultDiffs

Parameter

Type

Description

source_db_name

String

Source database name.

source_table_name

String

Table name of the source database.

ContentCompareDiff

Array of ContentCompareDiff objects

The value comparison results are different.

content_compare_diff_count

Integer

Total number of differences in the value comparison result.

Table 17 ContentCompareDiff

Parameter

Type

Description

target_select_sql

String

Query the SQL statements of the destination database.

source_select_sql

String

Query the SQL statements of the source database.

source_key_value

Array of strings

Key value list of the source database.

target_key_value

Array of strings

Key value list of the destination database.

Table 18 CompareTaskListResult

Parameter

Type

Description

compare_task_list

Array of CompareTaskList objects

List of comparison tasks.

compare_task_list_count

Integer

Total number of comparison tasks.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

Table 19 CompareTaskList

Parameter

Type

Description

compare_task_id

String

ID of a comparison task.

compare_type

String

Type of a comparison task.

compare_task_status

String

Status of a comparison task.

Values:

  • RUNNING: The instance is running.

  • WAITING_FOR_RUNNING: waiting to be started

  • SUCCESSFUL: complete

  • FAILED: The migration task failed.

  • CANCELLED: canceled

  • TIMEOUT_INTERRUPT: timeout interrupt

  • FULL_DOING: Full verification is in progress

  • INCRE_DOING: incremental verification in progress

create_time

String

Comparison start time

end_time

String

Comparison end time

Example Request

Request for querying the comparison result:

https://{Endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/query-compare-result
{
  "job_id" : "94800607-3cd8-4f7d-a340-63a10f8jb502",
  "object_level_compare_id" : "dc1683d9-bdf2-4be9-967f-6ef0953369bc",
  "line_compare_id" : "d45d569d-0a80-4cef-a412-da2a3bcdc9b7",
  "content_compare_id" : "79e206e6-13eb-4556-8cd5-c994c9cbd4e6",
  "current_page" : 1,
  "per_page" : 2
}

Example Response

Status code: 200

OK

{
  "job_id" : "c6e65e6a-de99-4112-9697-7c1923ajb201",
  "object_level_compare_results" : {
    "compare_task_id" : "dc1683d9-bdf2-4be9-967f-6ef0953369bc",
    "object_compare_overview" : [ {
      "object_type" : "DB",
      "object_compare_result" : "CONSISTENT",
      "source_count" : 1,
      "target_count" : 1,
      "diff_count" : 0
    }, {
      "object_type" : "INDEX",
      "object_compare_result" : "CONSISTENT",
      "source_count" : 12,
      "target_count" : 12,
      "diff_count" : 0
    }, {
      "object_type" : "TABLE",
      "object_compare_result" : "CONSISTENT",
      "source_count" : 6,
      "target_count" : 6,
      "diff_count" : 0
    } ],
    "object_compare_details" : {
      "TABLE" : [ {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_db_value" : "add_table_name_0",
        "target_db_value" : "add_table_name_0"
      }, {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_db_value" : "table_name_3",
        "target_db_value" : "table_name_3"
      } ],
      "INDEX" : [ {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_db_value" : "`add_table_name_0`.`PRIMARY`",
        "target_db_value" : "`add_table_name_0`.`PRIMARY`"
      }, {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_db_value" : "`add_table_name_0`.`bak0`",
        "target_db_value" : "`add_table_name_0`.`bak0`"
      } ],
      "DB" : [ {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_db_value" : "may_5",
        "target_db_value" : "may_5"
      } ]
    }
  },
  "line_compare_results" : {
    "compare_task_id" : "d45d569d-0a80-4cef-a412-da2a3bcdc9b7",
    "line_compare_overview" : [ {
      "source_db_name" : "may_5",
      "target_db_name" : "may_5",
      "line_compare_result" : "INCONSISTENT"
    } ],
    "line_compare_overview_count" : 1,
    "line_compare_details" : [ {
      "source_db_name" : "may_5",
      "line_compare_detail" : [ {
        "source_table_name" : "table_name_0",
        "source_row_num" : 0,
        "target_table_name" : "table_name_0",
        "target_row_num" : 1,
        "diff_row_num" : 1,
        "line_compare_result" : "INCONSISTENT"
      }, {
        "source_table_name" : "table_name_1",
        "source_row_num" : 0,
        "target_table_name" : "table_name_1",
        "target_row_num" : 0,
        "diff_row_num" : 0,
        "line_compare_result" : "CONSISTENT"
      } ],
      "line_compare_detail_count" : 2
    } ]
  },
  "content_compare_results" : {
    "compare_task_id" : "79e206e6-13eb-4556-8cd5-c994c9cbd4e6",
    "content_compare_overview" : [ {
      "source_db_name" : "may_5",
      "target_db_name" : "may_5",
      "content_compare_result" : "INCONSISTENT"
    } ],
    "content_compare_overview_count" : 1,
    "content_compare_details" : [ {
      "source_db_name" : "may_5",
      "content_compare_detail" : [ {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_table_name" : "table_name_0",
        "target_table_name" : "table_name_0",
        "source_row_num" : 0,
        "target_row_num" : 1,
        "diff_row_num" : 1,
        "line_compare_result" : "INCONSISTENT",
        "content_compare_result" : "INCONSISTENT"
      }, {
        "source_db_name" : "may_5",
        "target_db_name" : "may_5",
        "source_table_name" : "table_name_1",
        "target_table_name" : "table_name_1",
        "source_row_num" : 0,
        "target_row_num" : 0,
        "diff_row_num" : 0,
        "line_compare_result" : "CONSISTENT",
        "content_compare_result" : "CONSISTENT"
      } ],
      "content_compare_detail_count" : 2,
      "content_uncompare_detail" : [ ],
      "content_uncompare_detail_count" : 0
    } ],
    "content_compare_diffs" : [ {
      "source_db_name" : "may_5",
      "source_table_name" : "table_name_0",
      "content_compare_diff" : [ {
        "target_key_value" : [ "5" ],
        "target_select_sql" : "select * from may_5.table_name_0 where id = 5"
      } ],
      "content_compare_diff_count" : 1
    } ]
  },
  "compare_task_list_results" : {
    "compare_task_list_count" : 8,
    "compare_task_list" : [ {
      "compare_task_id" : "08cad1f8-9de2-42fa-b8ce-6c36daf730f6",
      "compare_type" : "contents",
      "compare_task_status" : "SUCCESSFUL",
      "create_time" : "1607766111833",
      "end_time" : "1607766310812"
    }, {
      "compare_task_id" : "dc1683d9-bdf2-4be9-967f-6ef0953369bc",
      "compare_type" : "object_comparison",
      "compare_task_status" : "SUCCESSFUL",
      "create_time" : "1607766110535",
      "end_time" : "1607766127373"
    } ]
  }
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.