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

Pra*_*oya 6 druid

我试图将以下德鲁伊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;
Run Code Online (Sandbox Code Playgroud)

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" ]
}
Run Code Online (Sandbox Code Playgroud)

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

yur*_*mix 0

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

如果是前者,我可以建议一些线索来调试此问题:

  1. 确保查询正确发送到Broker,如Druid的查询教程所示:

curl -X 'POST' -H 'Content-Type:application/json' -d @query-file.json http://<BROKER-IP>:<BROKER-PORT>/druid/v2?pretty

  1. 另外,检查代理日志是否有错误。