Group by Query does not seem to work when Content-type is X-jackson-smile

hi

i have trying to run a Group by(v2) query with the motivation

(1) reduce the size of data being streamed from druid to client

(2) keep the query payload in json format and response in X-jackson-smile.

So To accomplish point(2),

i did the following:

postRequest.setHeader(“Content-Type”, “application/x-jackson-smile”); // to honor Produces

and encoded the POST payload to smile with help from [here](https://github.com/kiha/jackson/blob/master/src/perf/TestJsonPerf.java). (convertToSmile method)

The Post call errors out with

��errorPUnknown exception�errorMessage�Unexpected token (VALUE_STRING), expected FIELD_NAME: missing property 'queryType' that is to contain type id  (for class io.druid.query.Query)
 at [Source: HttpInputOverHTTP@ee1d650; line: -1, column: 4]��errorClassrcom.fasterxml.jackson.databind.JsonMappingException�host!�

i looked at the code and

The GroupBy POST resource in QueryResouce.java has the following Annotations

@Produces({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE})
@Consumes({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE, APPLICATION_SMILE})

so i believe the request should look like :

postRequest.setHeader(“Content-Type”, “application/json”); // to honor Consumes
postRequest.setHeader(“Accept”, “application/x-jackson-smile”); // to honor Produces

and we should create an object mapper based on Accept header rather than Content-Type header

as i would prefer to query to json (easy to code and read)

-------------------------- Sample Code ----------------------------

ObjectMapper mapper =new ObjectMapper();
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://broker:8082/druid/v2");

String queryPayload =
    "{ \"queryType\": \"groupBy\", \"dataSource\": \"testdata\", \"context\":{       \"chunkPeriod\":\"P1D\" }, \"granularity\": \"day\", \"dimensions\": [\"home_roi_4\"], \"filter\": {   \"type\": \"and\",   \"fields\": [     { \"type\": \"selector\", \"dimension\": \"home_roi_4\", \"value\": \"crap\" }   ] }, \"aggregations\": [   { \"type\": \"longSum\", \"name\": \"c\", \"fieldName\": \"numCALL\" },   { \"type\": \"longSum\", \"name\": \"s\", \"fieldName\": \"numSMS\" } ], \"intervals\": [ \"2016-12-01T00:00:00.000/2016-12-03T23:59:59.000\" ]\n" + "}");

postRequest.setHeader("Content-Type", "application/x-jackson-smile");

ByteArrayEntity input = new ByteArrayEntity(convertToSmile(mapper.writeValueAsBytes(queryPayload)));
postRequest.setEntity(input);

HttpResponse response = httpClient.execute(postRequest);

-------------------------- Sample Code end-------------------------

hi all,

i have created a pull request for keeping response format based on Accept header and query payload content type based on content-type