运行网址编码查询

版本 3.1.23.6

运行网址编码的查询。

这需要调用者使用 Looker 特定的语法(如下所示)将查询的说明符编码到网址查询部分。

通常,您需要使用某种方法,在 POST 正文中将参数作为 JSON 来创建和/或运行查询。此方法适用于确实需要将参数编码到单个“GET”请求的网址的情况。这与 Looker 界面设置“探索”网址格式的方式一致。

此处的参数与 JSON 正文格式非常相似,不同之处在于过滤器语法不正确。遗憾的是,这种格式导致目前无法通过本文档页面中的“试试看!”按钮调用此方法。但是,在手动创建网址或使用 Looker SDK 创建网址时,可调用此属性。

下面是一个内嵌查询网址示例:

https://looker.mycompany.com:19999/api/3.0/queries/models/thelook/views/inventory_items/run/json?fields=category.name,inventory_items.days_in_inventory_tier,products.count&f[category.name]=socks&sorts=products.count+desc+0&limit=500&query_timezone=America/Los_Angeles

使用 Ruby SDK 调用此端点时,请以哈希值的形式传递查询参数部分。与上述哈希匹配的哈希值如下所示:

query_params =
{
  fields: "category.name,inventory_items.days_in_inventory_tier,products.count",
  :"f[category.name]" => "socks",
  sorts: "products.count desc 0",
  limit: "500",
  query_timezone: "America/Los_Angeles"
}
response = ruby_sdk.run_url_encoded_query('thelook','inventory_items','json', query_params)

同样,一般来说,在 POST 正文中使用传递完整查询的该方法会更轻松。 此方法适用于其他替代方案无法满足需求的情况。

支持的格式:

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

请求

GET /queries/models/{model_name}/views/{view_name}/run/{result_format}
数据类型
说明
请求
HTTP 请求
路径
HTTP 路径
展开 HTTPPath 定义...
model_name
字符串
模型名称
数据视图名称
字符串
视图名称
result_format
字符串
结果格式

响应

200:查询

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

400:错误请求

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

404:未找到

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

422:验证错误

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

429:请求数过多

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

示例

C#

https://github.com/looker-open-source/sdk-codegen/blob/main/csharp/sdk/3.1/methods.cs
https://github.com/looker-open-source/sdk-codegen/blob/main/csharp/sdk/4.0/methods.cs

Go

https://github.com/looker-open-source/sdk-codegen/blob/main/go/sdk/v4/methods.go

Kotlin

https://github.com/looker-open-source/sdk-codegen/blob/main/kotlin/src/main/com/looker/sdk/4.0/methods.kt
https://github.com/looker-open-source/sdk-codegen/blob/main/kotlin/src/main/com/looker/sdk/4.0/streams.kt

TypeScript

https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/3.1/funcs.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/3.1/methods.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/3.1/methodsInterface.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/3.1/streams.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/funcs.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/methods.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/methodsInterface.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/streams.ts
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk-codegen/src/python.gen.spec.ts

Python

https://github.com/looker-open-source/sdk-codegen/blob/main/python/looker_sdk/sdk/api31/methods.py
https://github.com/looker-open-source/sdk-codegen/blob/main/python/looker_sdk/sdk/api40/methods.py

Swift

https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/sdk/methods.swift
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/sdk/streams.swift)