jackjlli commented on a change in pull request #4964: Sql query endpoint
URL: https://github.com/apache/incubator-pinot/pull/4964#discussion_r363910978
 
 

 ##########
 File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
 ##########
 @@ -103,4 +100,60 @@ public String processQueryPost(String query) {
       throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
     }
   }
+
+  @GET
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("sql")
+  @ApiOperation(value = "Querying pinot in sql")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Query response"), 
@ApiResponse(code = 500, message = "Internal Server Error")})
+  public String processSqlQueryGet(@ApiParam(value = "Query", required = true) 
@QueryParam("sql") String query,
+      @ApiParam(value = "Trace enabled") @QueryParam(Request.TRACE) String 
traceEnabled,
+      @ApiParam(value = "Debug options") @QueryParam(Request.DEBUG_OPTIONS) 
String debugOptions) {
+    try {
+      ObjectNode requestJson = JsonUtils.newObjectNode();
+      requestJson.put(Request.SQL, query);
+      String queryOptions = constructSqlQueryOptions();
+      requestJson.put(Request.QUERY_OPTIONS, queryOptions);
+      if (traceEnabled != null) {
+        requestJson.put(Request.TRACE, traceEnabled);
+      }
+      if (debugOptions != null) {
+        requestJson.put(Request.DEBUG_OPTIONS, debugOptions);
+      }
+      BrokerResponse brokerResponse = 
requestHandler.handleRequest(requestJson, null, new RequestStatistics());
+      return brokerResponse.toJsonString();
+    } catch (Exception e) {
+      LOGGER.error("Caught exception while processing GET request", e);
+      brokerMetrics.addMeteredGlobalValue(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 
1L);
+      throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+    }
+  }
+
+  @POST
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("sql")
+  @ApiOperation(value = "Querying pinot")
 
 Review comment:
   `"Querying pinot using sql"`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to