跳到主要内容

查询结果

调用前请先阅读概览,了解鉴权、请求约定和错误处理。

获取缓存的查询结果​

GET /api/v1/query/orgs/{orgSlug}/worksheet-query-results/{queryId} · Read · Member

以 JSON 返回查询的缓存结果。服务端会拼接缓存的各页结果,超过约 10,000 行后停止。

参数位置类型必填说明
orgSlug路径string是组织 ID。
queryId路径string是查询 ID。

响应示例。值均为字符串,SQL NULL 返回 null。

{
"success": true,
"data": {
"schema": [
{ "name": "id", "type": "Int32" },
{ "name": "name", "type": "Nullable(String)" }
],
"data": [["1", "alice"], ["2", null]]
}
}

下载查询结果(CSV)​

GET /api/v1/orgs/{orgSlug}/query/{queryId}/download · Read · Export

将查询的缓存结果下载为 CSV 文件。该查询必须通过 Query API 执行,且已经完成。

参数位置类型必填说明
orgSlug路径string是组织 ID。
queryId路径string是Query API 响应中的查询 ID。
dryRun查询string否设为 1 时只检查导出权限,不返回文件。

限制:

  • 文件包含一行表头,数据不超过 10,000 行。
  • 查询失败或结果不完整时,返回 HTTP 400。

示例:

curl --location 'https://api.databend.cn/api/v1/orgs/<organization-id>/query/<query-id>/download' \
--header 'X-DATABENDCLOUD-TOKEN: <api-token>' \
--output result.csv

响应:文件内容,带 Content-Disposition: attachment; filename="<query-id>.csv"。设置 dryRun=1 时,响应为:

{ "success": true }

下载查询结果(Excel)​

GET /api/v1/orgs/{orgSlug}/query/{queryId}/download-excel · Read · Export

与下载查询结果(CSV)相同。文件格式为 .xlsx,Content-Type 为 application/vnd.ms-excel。

欢迎体验 Databend Cloud

基于 Rust + 对象存储构建的新一代多模态数仓,一个平台即可进行 BI、向量、全文检索及地理空间分析。

支持标准 SQL,自动弹性伸缩,助您快速构建现代化数据平台。

注册即领 ¥200 代金券。

注册体验