预览待添加数据¶
按数据库或卷选择来源前,预览去重后的文件和表数量。确认数量后再添加来源。
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"']
}
]
}'
字段 |
类型 |
必填 |
说明 |
|---|---|---|---|
|
integer |
是 |
要预览来源选择的知识库 ID。 |
字段路径中的 [] 表示数组中的每一项。例如,source_selections[].kind 表示 source_selections 数组中每一项的 kind 字段。
字段 |
类型 |
必填 |
说明 |
|---|---|---|---|
|
array of object |
是 |
要预览的来源选择。 |
下面表格展开请求示例中 source_selections 数组的每一项;每一行是该数组项的一个字段。
字段 |
类型 |
必填 |
说明 |
|---|---|---|---|
|
string |
是 |
|
|
integer |
条件必填 |
|
|
integer |
条件必填 |
|
|
boolean |
是 |
|
|
array of integer |
条件必填 |
|
|
array of string |
条件必填 |
|
|
array of integer |
否 |
全选时要排除的 Catalog 表 ID。 |
|
array of string |
否 |
全选时要排除的 Catalog 文件 ID。 |
|
object |
否 |
按表名、文件名或扩展名进一步筛选。 |
下面表格展开请求示例中 source_selections[].filters 对象;每一行是该对象的一个字段。
字段 |
类型 |
必填 |
说明 |
|---|---|---|---|
|
string |
否 |
表名筛选条件。 |
|
string |
否 |
文件名筛选条件。 |
|
array of string |
否 |
文件扩展名筛选条件。 |
选择范围
字段 |
类型 |
必填 |
说明 |
|---|---|---|---|
|
|
否 |
|
|
|
否 |
|
不能使用其他 |
成功响应¶
成功时返回 200。data 返回去重后的来源数量;确认数量后再添加来源。
{
"code": "OK",
"msg": "OK",
"data": {
"file_count": 2,
"table_count": 1,
"total_count": 3
}
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
成功时为 |
|
string |
成功时为 |
|
object |
响应数据。 |
下面表格展开响应示例中 data 对象;每一行是该对象的一个字段。
字段 |
类型 |
说明 |
|---|---|---|
|
integer |
去重后将添加的文件来源数。 |
|
integer |
去重后将添加的表来源数。 |
|
integer |
文件和表来源总数。 |
错误响应¶
{
"code": "ErrParamInvalid",
"msg": "invalid source selection",
"data": null
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
错误代码。 |
|
string |
面向调用者的错误信息。 |
|
null |
发生错误时为 |
后续操作¶
确认数量后添加数据源。