我正在编写一个查询,其结果将在 redash 上显示为仪表板。查询基本上是特定时间范围内几列表的总和:
SELECT
sum(col_A),
sum(col_B),
sum(col_C)
FROM
table_X
WHERE
timestamp > '2018-01-01'
AND timestamp < '2018-02-01'
Run Code Online (Sandbox Code Playgroud)
结果是这样的:
col_A col_B col_C
123 456 789
Run Code Online (Sandbox Code Playgroud)
但是,要在 redash 上正确呈现 dasboard,我需要长格式的结果:
column sum
col_A 123
col_B 456
col_C 789
Run Code Online (Sandbox Code Playgroud)
如何将结果从宽格式转换为长格式?
我有一个具有以下文档结构的集合:
{
"_id" : ObjectId("58aa706c658d1dc6c700002c"),
"source" : "web",
"type" : "Comentarios",
"email" : "jhondoe@xyz.com",
"updated_at" : ISODate("2017-02-20T04:28:28.623Z"),
"created_at" : ISODate("2017-02-20T04:28:28.623Z")
}
Run Code Online (Sandbox Code Playgroud)
我需要在Redash语法中构建一个查询以通过'_id'获取文档.我构建了以下查询,但总是出现错误:"查询格式无效.查询不是有效的JSON."
{
"collection": "commerce_messages",
"query" : {
"_id": "ObjectId(58aa706c658d1dc6c700002c)"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试将ObjectId括在引号上,但查询不返回结果.
我发现的唯一文档是在这个链接:https://redash.io/help/queries/querying_mongodb.html但他们没有解释如何查询ObjectId.
我正在尝试从Redash连接到本地Postgres。(都来自redash.io和http://0.0.0.0:5000/),但无法连接到它。我可以连接本地主机的其他工具,但是从Redash中我得到了错误:
Connection Test Failed:
could not connect to server: Connection refused Is the server running
on host "localhost" (::1) and accepting TCP/IP connections on port
5432? could not connect to server: Connection refused Is the server
running on host "localhost" (127.0.0.1) and accepting TCP/IP
connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
任何想法可能是什么问题?我将docker用于我的本地Redash,这可能会导致问题,但是我也从redash.io中得到了相同的错误。
这是我的docker-compose文件:
# This configuration file is for **development** setup. For production, refer to
# docker-compose.production.yml.
version: '2'
services:
server:
build: .
command: dev_server
depends_on:
- postgres
- redis
ports: …Run Code Online (Sandbox Code Playgroud)