Updated on 2024-08-23 GMT+08:00

Creating a Data-level Table Comparison Task

Function

This API is used to create a data-level table comparison task.

URI

POST /v3/{project_id}/jobs/{job_id}/table/compare

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

For details, see Obtaining a Project ID.

job_id

Yes

String

Task 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

Enumerated values:

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

Parameter

Mandatory

Type

Description

type

Yes

String

Comparison type.

  • lines: row comparison.
  • contents: value comparison.
  • random: sampling comparison. This function is available only for tasks from GaussDB Distributed to GaussDB Distributed, GaussDB Distributed to PostgreSQL, and GaussDB Primary/Standby to PostgreSQL.

start_time

No

String

Start time of a comparison task. The value is in timestamp format. If the value is empty, the task is started immediately.

compare_mode

No

String

Data-level comparison mode. If this parameter is left empty, object information needs to be transferred in compare_object or compare_object_with_token. quick_comparison indicates a quick comparison. Value: quick_comparison

Default value: quick_comparison

compare_object

No

Array of objects

Data-level comparison object.

For details, see Table 4.

options

No

Map<String,String>

Configuration item for a comparison task. The value is a key-value pair. Value comparison supports the following configuration items:

  • Comparison method. The key is contentCompareType. The value dynamic indicates a dynamic comparison, and the value static indicates a static comparison.
  • LOB comparison policy. The key is lobCompare. The value ignore indicates LOB data is ignored, and the value length indicates that LOB length is compared.

Row comparison supports the following configuration items:

  • Comparison policy configuration, which is applicable to many-to-one synchronization. The key is comparePolicy. The value normal indicates a one-to-one comparison, and the value manyToOne indicates a many-to-one comparison.

compare_object_with_token

No

Array of objects

Object for data-level comparison (Cassandra DR only, with token information).

For details, see Table 5.

compare_task_num

No

Integer

Number of comparison task threads. This parameter is available only for tasks of cloudDataGuard-cassandra and cloudDataGuard-gausscassandra-to-gausscassandra.

compare_transformation_infos

No

Array of objects

Data filtering information.

For details, see Table 7.

proportion_value

No

Double

Sampling ratio. Set this parameter when the comparison type is set to sampling comparison.

Table 4 Data structure description of field compare_object

Parameter

Mandatory

Type

Description

db_name

Yes

String

Database name.

table_name

No

Array of strings

List of table names in the database.

Table 5 Data structure description of field compare_object_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 6.

Table 6 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.

Table 7 Data structure description of field compare_transformation_infos

Parameter

Mandatory

Type

Description

object_info

Yes

Array of objects

Object information.

For details, see Table 8.

transformation_info

Yes

Object

Data filtering information.

For details, see Table 9.

Table 8 Data structure description of field object_info

Parameter

Mandatory

Type

Description

id

No

String

  • Database name and table name. For example, the format is t_auto_db---users, where t_auto_db is the database name and users is the table name.
  • Database name, schema name, and table name. For example, the format is t_auto_db---schema1---users, where t_auto_db is the database name, schema1 is the schema name, and users is the table name.
Table 9 Data structure description of field transformation_info

Parameter

Mandatory

Type

Description

transformation_type

Yes

String

Processing rule. The value is contentConditionalFilte.

value

Yes

String

Filtering condition. The value is an SQL condition statement, for example, id>100. The value contains a maximum of 256 characters.

Response Parameters

Status code: 202

Table 10 Response body parameters

Parameter

Type

Description

id

String

ID of a comparison task.

Example Request

  • Creating a data-level sampling comparison task
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/{job_id}/table/compare
    
    {
      "compare_object" : [ {
        "db_name" : "t_auto_db",
        "table_name" : [ ]
      } ],
      "options" : { },
      "proportion_value" : 20.1,
      "type" : "random"
    }
  • Creating a data-level dynamic value comparison task
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/{job_id}/table/compare
    
    {
      "compare_object" : [ {
        "db_name" : "t_auto_db",
        "table_name" : [ ]
      } ],
      "options" : {
        "contentCompareType" : "dynamic"
      },
      "start_time" : "1809366237000",
      "type" : "contents"
    }
  • Creating a row comparison task with data filtering enabled
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/{job_id}/table/compare
    
    {
      "compare_object" : [ ],
      "compare_transformation_infos" : [ {
        "object_info" : [ {
          "id" : "t_auto_db-*-*-test-*-*-users"
        } ],
        "transformation_info" : {
          "transformationType" : "contentConditionalFilter",
          "value" : "id>100"
        }
      } ],
      "type" : "lines"
    }

Example Response

Status code: 202

OK

{
  "id" : "6a0deb4a-ce39-449b-8c49-e0eed954c155"
}

Status code: 400

Bad Request

{
  "error_code" : "DRS.M00202",
  "error_msg" : "The value of jobId is invalid."
}

Status Code

Status Code

Description

202

OK

400

Bad Request

Error Code

For details, see Error Code.