预览待添加数据

按数据库或卷选择来源前,预览去重后的文件和表数量。确认数量后再添加来源。

POST https://api.moi.matrixorigin.cn/v5/semantic-models/{model_id}/source-selections/preview

调用前准备

先在 Catalog 中确认要选择的数据库、卷及其表和文件的标识。准备有目标工作区访问权限的个人访问令牌和目标工作区 ID。

该接口只预览 Catalog 数据。

请求体

curl -X POST "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID/source-selections/preview" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "source_selections": [
      {
        "kind": "database_tables",
        "database_id": '"$DATABASE_ID"',
        "all_selected": false,
        "selected_table_ids": ['"$TABLE_ID"']
      }
    ]
  }'

字段

类型

必填

说明

model_id

integer

是

要预览来源选择的知识库 ID。

字段路径中的 [] 表示数组中的每一项。例如,source_selections[].kind 表示 source_selections 数组中每一项的 kind 字段。

字段

类型

必填

说明

source_selections

array of object

是

要预览的来源选择。

下面表格展开请求示例中 source_selections 数组的每一项;每一行是该数组项的一个字段。

字段

类型

必填

说明

kind

string

是

database_tables 或 volume_files。

database_id

integer

条件必填

database_tables 的 Catalog Database ID。

volume_id

integer

条件必填

volume_files 的 Catalog Volume ID。

all_selected

boolean

是

true 选择当前范围内全部对象;false 时必须提供对应的显式选择 ID。

selected_table_ids

array of integer

条件必填

all_selected 为 false 时,显式选中的 Catalog 表 ID。

selected_file_ids

array of string

条件必填

all_selected 为 false 时,显式选中的 Catalog 文件 ID。

excluded_table_ids

array of integer

否

全选时要排除的 Catalog 表 ID。

excluded_file_ids

array of string

否

全选时要排除的 Catalog 文件 ID。

filters

object

否

按表名、文件名或扩展名进一步筛选。

下面表格展开请求示例中 source_selections[].filters 对象;每一行是该对象的一个字段。

字段

类型

必填

说明

table_name

string

否

表名筛选条件。

file_name

string

否

文件名筛选条件。

file_ext

array of string

否

文件扩展名筛选条件。

选择范围

字段

类型

必填

说明

Catalog Database

database_tables

否

selected_table_ids

Catalog Volume

volume_files

否

selected_file_ids

不能使用其他 kind 或非 Catalog 数据源。

成功响应

成功时返回 200。data 返回去重后的来源数量;确认数量后再添加来源。

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "file_count": 2,
    "table_count": 1,
    "total_count": 3
  }
}

字段

类型

说明

code

string

成功时为 OK。

msg

string

成功时为 OK。

data

object

响应数据。

下面表格展开响应示例中 data 对象;每一行是该对象的一个字段。

字段

类型

说明

file_count

integer

去重后将添加的文件来源数。

table_count

integer

去重后将添加的表来源数。

total_count

integer

文件和表来源总数。

错误响应

{
  "code": "ErrParamInvalid",
  "msg": "invalid source selection",
  "data": null
}

字段

类型

说明

code

string

错误代码。

msg

string

面向调用者的错误信息。

data

null

发生错误时为 null。

后续操作

确认数量后添加数据源。

最后更新于