

Druid Query in JSON
source link: https://fann.im/blog/2019/04/11/druid-query-in-json/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Druid Query in JSON
Apr 11, 2019
Druid 可以在 Superset SQL 查询,除此之外可以通过 HTTP+JSON 查询:
curl -X POST '<host:<port>/druid/v2/?pretty' -H 'Content-Type:application/json' -H 'Accept:application/json' -d @query.json
{
"queryType": "timeseries",
"dataSource": "cpm_log",
"granularity": "hour",
"aggregations": [
{
"type": "longSum",
"name": "requests",
"fieldName": "req_count_raw"
},
{
"type": "longSum",
"name": "impressions",
"fieldName": "win_count"
},
{
"type": "floatSum",
"name": "revenues",
"fieldName": "win_price"
}
],
"postAggregations": [
{
"type":"arithmetic",
"name": "ecpm",
"fn": "/",
"fields": [
{
"type": "fieldAccess",
"name": "postAgg_rev",
"fieldName": "revenues"
},
{
"type": "fieldAccess",
"name": "postAgg_imps",
"fieldName": "impressions"
}
]
}
],
"filter": {
"type": "and",
"fields": [
{
"type": "selector",
"dimension": "device_os",
"value": "android"
},
{
"type": "in",
"dimension": "req_ad_type",
"values": ["banner"]
}
]
},
"context": {
"grandTotal": true
},
"intervals": [
"2019-04-09T00:00:00+08:00/2019-04-09T23:00:00+08:00"
]
}
- queryType 有
timeseries
,topN
,groupBy
,search
,timeBoundary
等 - 尽量少用 groupBy 查询,效率不高
- topN 查询是通过
metric
来排序 context
可以指定queryId
,这样可以通过DELETE /druid/v2/{queryId}
取消查询- 去重:
{"type": "cardinality", "name": "distinct_pid", "fields": ["ad_pid"]}
Was this page helpful?
Recommend
-
52
-
22
一、Druid介绍 Druid 是 MetaMarket 公司研发,专为海量数据集上的做高性能 OLAP (OnLine Analysis Processing)而设计的数据存储和分析系统,目前 Druid 已经在Apache基金会下孵化。Druid的主...
-
56
-
89
Druid 支持两种 Kafka 数据摄入方式: Push 通过 Tranquility; Pull 通过 Kafka Indexing Service。 Tranquility TODO Kafka Ind...
-
94
MiddleManager TODO Historical 堆内存 Historical 堆内存的使用: 部分未合并的 Segment 查询结果;
-
18
JSON_QUERY (Transact-SQL) 06/03/2020 2 minutes to read In this article Applies to:
-
12
How to Query JSON Data using SQL, LINQ, and ADO. NET
-
8
当前位置 : ZY笔记 /Bug /Druid Json查询interval时间问题 Druid Json查询interval时...
-
9
问题描述: 遇到一个网页提交的数据是 json 格式,但是里面传入的参数一个是 json query 的查询语句,一个是用户名,使用 Fiddle 可以重发看获取到返回结果,用 python 提交就不行,应该是 json 在传输的过程中没有被正确识别,求大佬指教。
-
7
jq (JSON Query utility for Bash CLI scripts) Define JMESPATH syntax in...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK