Quantile calculation

Hi,

I was trying to get the quantile value of a metric at query time in druid, for this i went through below document available.

https://druid.apache.org/docs/latest/development/extensions-core/datasketches-quantiles.html

But i am not able to figure out how to use this in my query.

{

“queryType” : “groupBy”,

“dataSource” : “Node_Raw”,

“granularity” : “minute”,

“intervals” : [ “2019-07-26T05:49:51.682Z/2019-07-26T08:49:51.682Z” ],

“descending” : “true”,

“aggregations” : [ {

“type” : “quantilesDoublesSketch”,

“name”: “check”,

“fieldName” : “Node_C_4”,

“k”: 256

} ],

“postAggregations” : [{

“type” : “quantilesDoublesSketchToQuantile”,

“name”: “quantilevalue”,

“field” : <post aggregator that refers to a DoublesSketch (fieldAccess or another post aggregator)>,

“fraction” : <fractional position in the hypothetical sorted stream, number from 0 to 1 inclusive>

}],

“virtualColumns” : ,

“filter” : null,

“dimensions” : [ {“COUNTER_GROUP_ID”} ]

}

Not able to figure out what should be used.

Can someone please guide me in using this.

Thanks in Advance…

Amit Kumar

Your aggregation builds a sketch called “check” (perhaps better to call it “sketch”) from “Node_C_4” values.
So your post-aggregation should grab this sketch and extract a quantile value from it. For example, rank 0.5 (median):

“postAggregations”: [{
“type”: “quantilesDoublesSketchToQuantile”,
“name”: “quantilevalue”,
“field”: {
“type”: “fieldAccess”,
“fieldName”: “check”
},
“fraction”: 0.5
}]