Hey,

I am working on a use-case where in I need the count of metrics whose value is greater than 0.

I went through the druid-documentation but could only find ways to aggregate on filtered dimensions and not metrics. And since my query has other aggregations as well, i cannot filter out the records. Hence, I thought of using javascript aggregators.

Following is the aggregator I have come up with:

{

“type”: “javascript”,

“name”: “cnt”,

“fieldNames”: [“metricName”],

“fnAggregate” : “function(current, a) { if(a===0 || a ===null ){return current;}else {return (current+1);}}”,

“fnCombine” : “function(partialA, partialB) { return partialA + partialB; }”,

“fnReset” : “function() { return 0; }”

}

However, this doesn’t seem to be giving the correct results! Can someone please point out if the logic is flawed or where am I going wrong?

Also, it would be great if someone could explain exactly how the javascript aggregator works

Thanks

Asra