vrajat commented on code in PR #13746: URL: https://github.com/apache/pinot/pull/13746#discussion_r1740893274
########## 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: Column data type check will identify it. IME, if there is a query with 20 columns, there will be 20 messages in the `differences` array while the real problem is just that columns are ordered differently. Anyway - it is unclear if this issue exists and can be detected as an improvement in the future. -- 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