Problem in TopNQuery with processing postAggregation result

Hi,
I found a problem in resultSet when try to query druid using topN query.

when I execute the following query directly on druid query node:

{

“queryType” : “topN”,

“dataSource” : {

“type” : “table”,

“name” : “druid-datasource”

},

“dimension” : {

“type” : “LegacyDimensionSpec”,

“dimension” : “contractLineId”,

“outputName” : “contractLineId”

},

“metric” : {

“type” : “LegacyTopNMetricSpec”,

“metric” : “impressions”

},

“threshold” : 10,

“intervals” : {

“type” : “LegacySegmentSpec”,

“intervals” : [ “2017-05-01T17:00:00.000+03:00/2017-07-21T17:00:00.000+03:00” ]

},

“filter” : null,

“granularity” : {

“type” : “all”

},

“aggregations” : [ {

“type” : “longSum”,

“name” : “bids”,

“fieldName” : “bids”

}, {

“type” : “longSum”,

“name” : “impressions”,

“fieldName” : “impressions”

}, {

“type” : “filtered”,

“aggregator” : {

“type” : “longSum”,

“name” : “bidWons”,

“fieldName” : “bids”

},

“filter” : {

“type” : “in”,

“dimension” : “biddingStatus”,

“values” : [ “WON” ],

“extractionFn” : null

},

“name” : “bidWons”

}, {

“type” : “filtered”,

“aggregator” : {

“type” : “longSum”,

“name” : “bidResponses”,

“fieldName” : “bids”

},

“filter” : {

“type” : “in”,

“dimension” : “biddingStatus”,

“values” : [ “first”, “second”, “third”, “WON” ],

“extractionFn” : null

},

“name” : “bidResponses”

} ],

“postAggregations” : [ {

“type” : “arithmetic”,

“name” : “winRate”,

“fn” : “*”,

“fields” : [ {

“type” : “arithmetic”,

“name” : “div”,

“fn” : “/”,

“fields” : [ {

“type” : “fieldAccess”,

“name” : “bidWons”,

“fieldName” : “bidWons”

}, {

“type” : “fieldAccess”,

“name” : “bidResponses”,

“fieldName” : “bidResponses”

} ],

“ordering” : null

}, {

“type” : “constant”,

“name” : “const”,

“value” : 100

} ],

“ordering” : null

}, {

“type” : “arithmetic”,

“name” : “bidRate”,

“fn” : “*”,

“fields” : [ {

“type” : “arithmetic”,

“name” : “div”,

“fn” : “/”,

“fields” : [ {

“type” : “fieldAccess”,

“name” : “bidResponses”,

“fieldName” : “bidResponses”

}, {

“type” : “fieldAccess”,

“name” : “bids”,

“fieldName” : “bids”

} ],

“ordering” : null

}, {

“type” : “constant”,

“name” : “const”,

“value” : 100

} ],

“ordering” : null

} ],

“context” : null,

“descending” : false

}

``

I receive the following result:

[

{

“timestamp”: “2017-06-09T11:00:00.000Z”,

“result”: [

{

“bidWons”: 6701,

“impressions”: 7310,

“bids”: 30081,

“bidResponses”: 9847,

“bidRate”: 32.734948971111336,

“winRate”: 68.05118310145221,

“contractLineId”: “127”

}]
}
]

``

But when I try to run the same query using io.druid.druid-server library i receive the following result :

[

{

“timestamp”: “2017-06-09T11:00:00.000Z”,

“result”: [

{

“bids”: 30081,

“bidResponses”: 9847,

“bidWons”: 6701,

“contract_impressions”: 7310,

“contractLineId”: “127”

}]
}
]

``

As you can see in the second result there are missing postAggregation metrics. I try to analyze the call with wireshark and I saw that in the second care server return the same values as in the first case.

And the problem is in TopNQueryQueryToolChest. As I understand right there are a method thats extract postAggregation values:

private static List<PostAggregator> prunePostAggregators(TopNQuery query)
{
  return AggregatorUtil.pruneDependentPostAgg(
      query.getPostAggregatorSpecs(),
      query.getTopNMetricSpec().getMetricName(query.getDimensionSpec())
  );
}

``

and the implementation of pruneDependentPostAgg:

/**

 * returns the list of dependent postAggregators that should be calculated in order to calculate given postAgg

You aren’t meant to use druid-server directly to make queries. I mean, you can do it if you want, but it’s not meant to be a public API. If you are going to use it, the simplest way is probably to use it only for serializing and deserializing queries and their responses. But use your favorite http client to actually make the query.

Thx Gian.