gortiz commented on code in PR #13746: URL: https://github.com/apache/pinot/pull/13746#discussion_r1740801249
########## pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java: ########## @@ -379,4 +456,85 @@ static Response getPinotQueryResponse(BrokerResponse brokerResponse) .entity((StreamingOutput) brokerResponse::toOutputStream).type(MediaType.APPLICATION_JSON) .build(); } + + @VisibleForTesting + static Response getPinotQueryComparisonResponse(String query, BrokerResponse v1Response, BrokerResponse v2Response) { + ObjectNode response = JsonUtils.newObjectNode(); + response.set("v1Response", JsonUtils.objectToJsonNode(v1Response)); + response.set("v2Response", JsonUtils.objectToJsonNode(v2Response)); + response.set("comparisonAnalysis", JsonUtils.objectToJsonNode(analyzeDifferences(query, v1Response, v2Response))); + + return Response.ok() + .header(PINOT_QUERY_ERROR_CODE_HEADER, -1) + .entity(response).type(MediaType.APPLICATION_JSON) + .build(); + } + + private static List<String> analyzeDifferences(String query, BrokerResponse v1Response, BrokerResponse v2Response) { + List<String> differences = new ArrayList<>(); + + if (v1Response.getExceptionsSize() != 0 || v2Response.getExceptionsSize() != 0) { + differences.add("Exception encountered while running the query on one or both query engines"); + return differences; + } + + if (v1Response.getResultTable() == null && v2Response.getResultTable() == null) { + return differences; + } + + if (v1Response.getResultTable() == null) { + differences.add("v1 response has an empty result table"); + return differences; + } + + if (v2Response.getResultTable() == null) { + differences.add("v2 response has an empty result table"); + return differences; + } + + DataSchema.ColumnDataType[] v1ResponseTypes = v1Response.getResultTable().getDataSchema().getColumnDataTypes(); Review Comment: AFAIR any simple select query without group by can return different results, even using the same engine. This should be more frequent if there are several segments involved in the query. In fact we would like to verify order if the query is order by and do not do that in the other case. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org