kfaraz commented on code in PR #17846:
URL: https://github.com/apache/druid/pull/17846#discussion_r2026113906


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/SegmentLoadStatusFetcher.java:
##########
@@ -238,13 +236,12 @@ private void updateStatus(State state, DateTime startTime)
    */
   private VersionLoadStatus fetchLoadStatusFromBroker() throws Exception
   {
-    Request request = brokerClient.makeRequest(HttpMethod.POST, 
"/druid/v2/sql/");
-    SqlQuery sqlQuery = new SqlQuery(StringUtils.format(LOAD_QUERY, 
datasource, versionsConditionString),
-                                     ResultFormat.OBJECTLINES,
+    ClientSqlQuery clientSqlQuery = new 
ClientSqlQuery(StringUtils.format(LOAD_QUERY, datasource, 
versionsConditionString),
+                                     ResultFormat.OBJECTLINES.contentType(),
                                      false, false, false, null, null
     );

Review Comment:
   Nit: formatting
   ```suggestion
       ClientSqlQuery clientSqlQuery = new ClientSqlQuery(
           StringUtils.format(LOAD_QUERY, datasource, versionsConditionString),
           ResultFormat.OBJECTLINES.contentType(),
           false, false, false, null, null
       );
   ```



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/SegmentLoadStatusFetcher.java:
##########
@@ -238,13 +236,12 @@ private void updateStatus(State state, DateTime startTime)
    */
   private VersionLoadStatus fetchLoadStatusFromBroker() throws Exception
   {
-    Request request = brokerClient.makeRequest(HttpMethod.POST, 
"/druid/v2/sql/");
-    SqlQuery sqlQuery = new SqlQuery(StringUtils.format(LOAD_QUERY, 
datasource, versionsConditionString),
-                                     ResultFormat.OBJECTLINES,
+    ClientSqlQuery clientSqlQuery = new 
ClientSqlQuery(StringUtils.format(LOAD_QUERY, datasource, 
versionsConditionString),
+                                     ResultFormat.OBJECTLINES.contentType(),
                                      false, false, false, null, null
     );
-    request.setContent(MediaType.APPLICATION_JSON, 
objectMapper.writeValueAsBytes(sqlQuery));
-    String response = brokerClient.sendQuery(request);
+    ListenableFuture<String> futureResponse = 
brokerClient.submitSqlQuery(clientSqlQuery);
+    String response = futureResponse.get();

Review Comment:
   ```suggestion
       final String response = 
FutureUtils.get(brokerClient.submitSqlQuery(clientSqlQuery), true);
   ```



##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/SegmentLoadStatusFetcherTest.java:
##########
@@ -148,9 +156,10 @@ public String answer(InvocationOnMock invocation) throws 
Throwable
             5 - timesInvoked,
             0
         );
-        return new ObjectMapper().writeValueAsString(loadStatus);
+        String jsonResponse = new 
ObjectMapper().writeValueAsString(loadStatus);

Review Comment:
   Pull the object mapper out into a constant.



##########
server/src/main/java/org/apache/druid/client/broker/BrokerClientImpl.java:
##########
@@ -46,6 +45,19 @@ public BrokerClientImpl(final ServiceClient client, final 
ObjectMapper jsonMappe
     this.jsonMapper = jsonMapper;
   }
 
+  @Override
+  public ListenableFuture<String> submitSqlQuery(final ClientSqlQuery sqlQuery)
+  {
+    return FutureUtils.transform(
+        client.asyncRequest(
+            new RequestBuilder(HttpMethod.POST, "/druid/v2/sql/")
+                    .jsonContent(jsonMapper, sqlQuery),
+            new BytesFullResponseHandler()
+        ),
+        holder -> JacksonUtils.readValue(jsonMapper, holder.getContent(), 
String.class)

Review Comment:
   ```suggestion
           FullResponseHolder::getContent
   ```



##########
server/src/main/java/org/apache/druid/client/broker/BrokerClientImpl.java:
##########
@@ -46,6 +45,19 @@ public BrokerClientImpl(final ServiceClient client, final 
ObjectMapper jsonMappe
     this.jsonMapper = jsonMapper;
   }
 
+  @Override
+  public ListenableFuture<String> submitSqlQuery(final ClientSqlQuery sqlQuery)
+  {
+    return FutureUtils.transform(
+        client.asyncRequest(
+            new RequestBuilder(HttpMethod.POST, "/druid/v2/sql/")
+                    .jsonContent(jsonMapper, sqlQuery),
+            new BytesFullResponseHandler()

Review Comment:
   ```suggestion
               new StringFullResponseHandler(StandardCharsets.UTF_8)
   ```



-- 
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]

Reply via email to