gpt4 book ai didi

druid - Apache Druid sql 查询转换为基于 json 的查询

转载 作者:行者123 更新时间:2023-12-04 16:04:33 26 4
gpt4 key购买 nike

我正在尝试将以下德鲁伊 sql 查询转换为德鲁伊 json 查询,因为我拥有的列之一是多值维度,德鲁伊不支持 sql 样式查询。

我的sql查询:

SELECT date_dt, source, type_labels, COUNT(DISTINCT unique_p_hll)
FROM "test"
WHERE
type_labels = 'z' AND
(a_id IN ('a', 'b', 'c') OR b_id IN ('m', 'n', 'p'))
GROUP BY date_dt, source, type_labels;
unique_p_hll是具有唯一性的 hll 列。

我想出的德鲁伊 json 查询如下:

{
"queryType": "groupBy",
"dataSource": "test",
"granularity": "day",
"dimensions": ["source", "type_labels"],
"limitSpec": {},
"filter": {
"type": "and",
"fields": [
{ "type": "selector", "dimension": "type_labels", "value": "z" },
{ "type": "or", "fields": [
{ "type": "in", "dimension": "a_id", "values": ["a", "b", "c"] },
{ "type": "in", "dimension": "b_id", "values": ["m", "n", "p"] }
]}
]
},
"aggregations": [
{ "type": "longSum", "name": "unique_p_hll", "fieldName": "p_id" }
],
"intervals": [ "2018-08-01/2018-08-02" ]
}

但是 json 查询似乎返回空的结果集。
我可以在 Pivot UI 中正确看到输出。虽然数组列 type_labels值显示为 {"array_element": "z"}而不是简单的 "z" .

最佳答案

查询是返回空字符串,还是返回带零记录的格式化 JSON?

如果是前者,我可以建议几个线索来调试这个问题:

  • 确保查询正确发送到 Broker,如 Druid's query tutorial 所示:
  • curl -X 'POST' -H 'Content-Type:application/json' -d @query-file.json http://<BROKER-IP>:<BROKER-PORT>/druid/v2?pretty
  • 此外,请检查 Broker 的日志是否有错误。
  • 关于druid - Apache Druid sql 查询转换为基于 json 的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52011135/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com