运行查询

版本 4.0.23.4

运行已保存的查询。

这会运行之前保存的查询。您可以对在 Looker 界面生成的查询或使用 API 明确创建的查询使用此方法。您还可从已保存的“Look”中使用查询“id”。

“result_format”参数用于指定所需的响应结构和响应格式。

支持的格式:

result_format 说明
json 纯 json
json_detail 行数据以及描述查询的字段、数据透视表、表计算和其他方面的元数据
csv 以英文逗号分隔的值,带有标题
txt 使用标头制表符分隔值
html 简单 HTML
MD 简单 Markdown
XX MS Excel 电子表格
sql 返回生成的 SQL,而不是运行查询
png 查询可视化图表的 PNG 图片
jpg 查询可视化的 JPG 图片

请求

GET /queries/{query_id}/run/{result_format}
数据类型
说明
请求
HTTP 请求
路径
HTTP 路径
展开 HTTPPath 定义...
查询 ID
字符串
查询的 ID
result_format
字符串
结果格式
查询
HTTPQuery
展开 HTTPQuery 定义...
限制
整数
行数上限(可能会覆盖已保存查询中的上限)。
apply_formatting
布尔值
为每个模型应用模型指定的格式。
apply_vis
布尔值
将可视化选项应用于结果。
缓存
布尔值
从缓存中获取结果(如果有)。
图片宽度
整数
图片格式的呈现宽度。
图片高度
整数
图片格式的呈现高度。
generate_drill_links
布尔值
生成深入链接(仅适用于“json_detail”格式)。
force_production
布尔值
强制使用生产模型,即使用户处于开发模式。请注意,此标记为 false 并不保证将使用开发模型。
仅缓存
布尔值
从缓存中检索任何结果,即使结果已过期。
路径前缀
字符串
用于细目链接(网址编码)的前缀。
重新构建_pdts
布尔值
重新构建查询中使用的 PDTS。
server_table_calcs
布尔值
对查询结果执行表计算
source
字符串
指定此调用的来源。

响应

200:查询

数据类型
说明
(字符串)
字符串

400:错误请求

数据类型
说明
(对象)
消息
字符串
错误详情
文档网址
字符串
文档链接

404:未找到

数据类型
说明
(对象)
消息
字符串
错误详情
文档网址
字符串
文档链接

422:验证错误

数据类型
说明
(对象)
消息
字符串
错误详情
展开 ValidationErrorDetail 定义...
字段
字符串
出错的字段
代码
字符串
错误代码
消息
字符串
错误信息消息
文档网址
字符串
文档链接
文档网址
字符串
文档链接

429:请求数过多

数据类型
说明
(对象)
消息
字符串
错误详情
文档网址
字符串
文档链接

示例

Python

https://github.com/looker-open-source/sdk-codegen/blob/main/examples/python/cloud-function-write-to-bigquery/main.py
https://github.com/looker-open-source/sdk-codegen/blob/main/python/tests/integration/test_methods.py
https://github.com/looker-open-source/sdk-codegen/blob/main/python/tests/integration/test_methods.py
https://github.com/looker-open-source/sdk-codegen/blob/main/python/tests/integration/test_methods.py

Kotlin

https://github.com/looker-open-source/sdk-codegen/blob/main/kotlin/src/test/TestMethods.kt
https://github.com/looker-open-source/sdk-codegen/blob/main/kotlin/src/test/TestMethods.kt

TypeScript

https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-node/test/methods.spec.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-node/test/methods.spec.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-node/test/methods.spec.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-node/test/methods.spec.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-node/test/methods.spec.ts

Swift

https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/Tests/lookerTests/smokeTests.swift)
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/Tests/lookerTests/smokeTests.swift)
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/Tests/lookerTests/smokeTests.swift)
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/Tests/lookerTests/smokeTests.swift)