计算德鲁伊中一个维度的不同
Count Distinct of a dimension in druid
我正在尝试区分维度领土的计数。但我认为我得到的与(日期,领土)的计数不同。
这是查询:
{
"queryType": "groupBy",
"dataSource": "model",
"granularity": "all",
"filter": {
"type": "selector", "dimension": "District", "value": "ATLANTA"},
"aggregations":[
{"name":"!t5", "type":"distinctCount","fieldName":"Territory"},
{"name":"!T_4","type":"longSum","fieldName":"Units"}
],
"postAggregations":[
{
"type":"arithmetic",
"fn":"*",
"fields":[
{
"type":"arithmetic",
"fn":"/",
"fields":[
{
"type":"fieldAccess",
"fieldName":"!T_4"
},
{
"type":"fieldAccess",
"fieldName":"!t5"
}
]
},
{
"type":"constant",
"value":1
}
],
"name":"AverageDistrict"
}
],
"intervals": ["2018-06-13T00:00Z/2018-07-25T00:00Z"]
}
所以当我更改日期范围时,distinct(!t5) 的计数也会增加。而在原始数据中,不同的计数在所有日期范围内始终保持不变。
我需要的是该日期范围内不同领土值的计数。我希望我已经说清楚了。
尝试使用 'cardinality' 聚合器代替 'distinctCount' 聚合器。希望这有帮助。
我正在尝试区分维度领土的计数。但我认为我得到的与(日期,领土)的计数不同。 这是查询:
{
"queryType": "groupBy",
"dataSource": "model",
"granularity": "all",
"filter": {
"type": "selector", "dimension": "District", "value": "ATLANTA"},
"aggregations":[
{"name":"!t5", "type":"distinctCount","fieldName":"Territory"},
{"name":"!T_4","type":"longSum","fieldName":"Units"}
],
"postAggregations":[
{
"type":"arithmetic",
"fn":"*",
"fields":[
{
"type":"arithmetic",
"fn":"/",
"fields":[
{
"type":"fieldAccess",
"fieldName":"!T_4"
},
{
"type":"fieldAccess",
"fieldName":"!t5"
}
]
},
{
"type":"constant",
"value":1
}
],
"name":"AverageDistrict"
}
],
"intervals": ["2018-06-13T00:00Z/2018-07-25T00:00Z"]
}
所以当我更改日期范围时,distinct(!t5) 的计数也会增加。而在原始数据中,不同的计数在所有日期范围内始终保持不变。 我需要的是该日期范围内不同领土值的计数。我希望我已经说清楚了。
尝试使用 'cardinality' 聚合器代替 'distinctCount' 聚合器。希望这有帮助。