查询数据对比表汇总
查询指定数据对比任务某次执行的表级对比结果,支持按库名、Schema 名称或表名关键字筛选。
请求地址:/openapi/v1/comparedata/result/tableSummary
请求方法:GET
调用前准备
taskId可通过 创建数据对比任务 的成功响应data获取。execId可通过 启动数据对比任务 的成功响应data获取,也可以通过 查询数据对比主任务详情 返回的data.lastExecId获取。
请求参数
| 参数 | 类型 | 是否必填 | 说明 | 示例 |
|---|---|---|---|---|
| taskId | String | 是 | 数据对比主任务 ID。 | cd-tg3isu1xgs |
| execId | Integer | 是 | 数据对比任务某次执行的子任务 ID。 | 326816 |
| schemaName | String | 否 | 数据库名或 Schema 名称过滤条件。一个任务对比多个库或 Schema 时,可通过该参数缩小查询范围。 | a2a |
| tableNameLike | String | 否 | 表名模糊搜索条件。对于 PostgreSQL 或 SQL Server 等数据源,取值通常可使用 public.table_name 或 dbo.table_name 格式。 | popup |
| pageSize | Integer | 否 | 每页记录数,默认为 30,最大为 100。 | 30 |
| pageNumber | Integer | 否 | 当前页码,默认从 1 开始。 | 1 |
返回参数
| 参数 | 类型 | 说明 | 示例 |
|---|---|---|---|
| success | Boolean | 请求是否成功。 | true |
| requestId | String | 请求 ID,可用于问题排查和链路追踪。 | Ta7q9BNC-jppqeSZnkkrr3TWdlmc7PAK |
| data | Object | 表级对比汇总对象。 | 见下方字段说明 |
data 字段说明
| 参数 | 类型 | 说明 | 示例 |
|---|---|---|---|
| taskId | String | 数据对比主任务 ID。 | cd-tg3isu1xgs |
| execId | Integer | 本次查询的数据对比执行 ID。 | 326816 |
| totalTableCount | Integer | 满足过滤条件的表总数。 | 1 |
| diffTableCount | Integer | 存在不一致数据的表总数。 | 1 |
| pageNumber | Integer | 当前返回的页码。 | 1 |
| pageSize | Integer | 每页记录数。 | 30 |
| tableSummaries | Array | 表级汇总信息列表。 | 见下方字段说明 |
tableSummaries 字段说明
| 参数 | 类型 | 说明 | 示例 |
|---|---|---|---|
| progressId | Integer | 单个表对比结果的唯一标识。查询不一致详情或订正 SQL 时需要传入该值。 | 2934527 |
| schemaName | String | 源端数据库名或 Schema 名称。 | a2a |
| tableName | String | 源端表名。对于 database/schema/table 层级的数据源,可包含 Schema 和表名。 | t_popup_control_src |
| targetSchemaName | String | 目标端数据库名或 Schema 名称。 | a2a |
| targetTableName | String | 目标端表名。 | t_popup_control_target |
| status | String | 表对比状态。取值包括:Unstarted、Comparing、Failed、Skipped、Success。 | Success |
| sourceTotalRows | Long | 源端表记录数。 | 5 |
| targetTotalRows | Long | 目标端表记录数。 | 6 |
| sourceOnlyCount | Long | 仅源端存在的记录数。 | 3 |
| targetOnlyCount | Long | 仅目标端存在的记录数。 | 4 |
| mismatchCount | Long | 主键相同但字段值不同的记录数。 | 1 |
| errorMessage | String | 表状态为失败或跳过时返回的异常原因。 | "" |
| primaryKeyColumns | String | 主键或唯一键字段名列表。 | control_id |
| columnsMapping | String | 源端和目标端字段映射关系,通常为 JSON 字符串。 | {"control_id":"origin_id"} |
请求示例
{
"taskId": "cd-tg3isu1xgs",
"execId": 326816,
"pageNumber": 1,
"pageSize": 30
}
调用成功示例
{
"success": true,
"requestId": "Ta7q9BNC-jppqeSZnkkrr3TWdlmc7PAK",
"data": {
"taskId": "cd-tg3isu1xgs",
"execId": 326816,
"totalTableCount": 1,
"diffTableCount": 1,
"pageNumber": 1,
"pageSize": 30,
"tableSummaries": [
{
"progressId": 2934527,
"schemaName": "a2a",
"tableName": "t_popup_control_src",
"targetSchemaName": "a2a",
"targetTableName": "t_popup_control_target",
"status": "Success",
"sourceTotalRows": 5,
"targetTotalRows": 6,
"sourceOnlyCount": 3,
"targetOnlyCount": 4,
"mismatchCount": 1,
"primaryKeyColumns": "control_id",
"columnsMapping": "{\"control_id\":\"origin_id\",\"popup_name\":\"popup_name\",\"app_id\":\"app_id\"}"
}
]
}
}