distinct_count should return integer instead of floating value in druid

The distinct_count returns floating value but it shouldn’t. As user count cannot be some fraction. What can I do to get integer value from it?

You’re using (i suspect) a hyperUnique aggregator to get your distinct count - this isn’t an exact value but an approximation (+/-3%, I think), so it will return a float. To get the query to output an integer, you have to realise the hyperUnique in one post-aggregator, then use another javascript postagg to round it, e.g.:

“postAggregations” : [{

  "type"  : "hyperUniqueCardinality",

  "name"  :"postagg1",

  "fieldName": "my_hyperunique_aggregator" 

}, {

  "type"  : "javascript",

  "name"  :"rounded_count",

  "fieldNames": ["postagg1"],

  "function": "function(postagg1) { return Math.round(postagg1); }"