yashmayya commented on code in PR #13746:
URL: https://github.com/apache/pinot/pull/13746#discussion_r1740718124
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -359,6 +359,8 @@ public static class Broker {
public static class Request {
public static final String SQL = "sql";
+ public static final String V1SQL = "v1sql";
Review Comment:
The official docs do use the v1 and v2 terminology as well -
https://docs.pinot.apache.org/reference/single-stage-engine,
https://docs.pinot.apache.org/developers/advanced/v2-multi-stage-query-engine
and it seems more succinct and clear to say `v1sql` than something like
`ssqeSql`.
##########
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");
Review Comment:
The query response itself contains the entire v1 and v2 responses which will
have the exceptions. It seems redundant to duplicate that here?
##########
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:
I'm not aware of any such cases where the column ordering differs in the two
engines. However, we do check for column data type mismatches.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]