gortiz commented on code in PR #13746:
URL: https://github.com/apache/pinot/pull/13746#discussion_r1771476794
##########
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java:
##########
@@ -236,6 +243,78 @@ public void processSqlWithMultiStageQueryEnginePost(String
query, @Suspended Asy
}
}
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("query/compare")
+ @ApiOperation(value = "Query Pinot using both the single-stage query engine
and the multi-stage query engine and "
+ + "compare the results. The 'sql' field should be set in the request
JSON to run the same query on both the "
+ + "query engines. Set '" + Request.V1SQL + "' and '" + Request.V2SQL +
"' if the query needs to be adapted for "
+ + "the two query engines.")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Query result comparison response"),
+ @ApiResponse(code = 500, message = "Internal Server Error")
+ })
+ @ManualAuthorization
+ public void processSqlQueryWithBothEnginesAndCompareResults(String query,
@Suspended AsyncResponse asyncResponse,
+ @Context org.glassfish.grizzly.http.server.Request requestContext,
+ @Context HttpHeaders httpHeaders) {
+ try {
+ JsonNode requestJson = JsonUtils.stringToJsonNode(query);
+ String v1Query;
+ String v2Query;
+ if (requestJson.has(Request.SQL)) {
+ v1Query = requestJson.get(Request.SQL).asText();
+ v2Query = v1Query;
+ } else if (requestJson.has(Request.V1SQL) &&
requestJson.has(Request.V2SQL)) {
+ v1Query = requestJson.get(Request.V1SQL).asText();
+ v2Query = requestJson.get(Request.V2SQL).asText();
+ } else {
+ throw new IllegalStateException("Payload should either contain the
query string field '" + Request.SQL + "' "
+ + "or both of '" + Request.V1SQL + "' and '" + Request.V2SQL +
"'");
+ }
Review Comment:
Can we support `sql` by default? I mean to still support `sql` when either
`sqlV1` or `sqlV2` are provided.
So the algorithm I suggest is:
```
v1Query = requestJson.has(Request.V1SQL) ? requestJson.get(Request.V1SQL)
else requestJson.get(Request.SQL)
```
and same for `v2Query`
This is similar to what we do in resource based query tests where there is a
`sql` field we use by default but if there is a `h2Sql` we use that one for h2.
--
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]