github-code-scanning[bot] commented on code in PR #14527:
URL: https://github.com/apache/druid/pull/14527#discussion_r1254679098


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java:
##########
@@ -562,35 +527,72 @@
         .build();
   }
 
+  @SuppressWarnings("ReassignedVariable")
   private Optional<ResultSetInformation> getSampleResults(
-      String asyncResultId,
-      boolean isSelectQuery,
+      String queryId,
       String dataSource,
-      SqlStatementState sqlStatementState
+      SqlStatementState sqlStatementState,
+      MSQDestination msqDestination
   )
   {
     if (sqlStatementState == SqlStatementState.SUCCESS) {
       Map<String, Object> payload = 
SqlStatementResourceHelper.getPayload(contactOverlord(overlordClient.taskReportAsMap(
-          asyncResultId)));
-      Optional<Pair<Long, Long>> rowsAndSize = 
SqlStatementResourceHelper.getRowsAndSizeFromPayload(
-          payload,
-          isSelectQuery
+          queryId)));
+      MSQTaskReportPayload msqTaskReportPayload = 
jsonMapper.convertValue(payload, MSQTaskReportPayload.class);
+      Optional<List<PageInformation>> pageList = 
SqlStatementResourceHelper.populatePageList(
+          msqTaskReportPayload,
+          msqDestination
       );
-      return Optional.of(new ResultSetInformation(
-          rowsAndSize.orElse(new Pair<>(null, null)).lhs,
-          rowsAndSize.orElse(new Pair<>(null, null)).rhs,
-          null,
-          dataSource,
-          // only populate sample results in case a select query is successful
-          isSelectQuery ? 
SqlStatementResourceHelper.getResults(payload).orElse(null) : null,
-          ImmutableList.of(
-              new PageInformation(
-                  rowsAndSize.orElse(new Pair<>(null, null)).lhs,
-                  rowsAndSize.orElse(new Pair<>(null, null)).rhs,
-                  0
-              )
+
+      // getting the total number of rows, size from page information.
+      Long rows = 0L;

Review Comment:
   ## Boxed variable is never null
   
   The variable 'rows' is only assigned values of primitive type and is never 
'null', but it is declared with the boxed type 'Long'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5224)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java:
##########
@@ -562,35 +527,72 @@
         .build();
   }
 
+  @SuppressWarnings("ReassignedVariable")
   private Optional<ResultSetInformation> getSampleResults(
-      String asyncResultId,
-      boolean isSelectQuery,
+      String queryId,
       String dataSource,
-      SqlStatementState sqlStatementState
+      SqlStatementState sqlStatementState,
+      MSQDestination msqDestination
   )
   {
     if (sqlStatementState == SqlStatementState.SUCCESS) {
       Map<String, Object> payload = 
SqlStatementResourceHelper.getPayload(contactOverlord(overlordClient.taskReportAsMap(
-          asyncResultId)));
-      Optional<Pair<Long, Long>> rowsAndSize = 
SqlStatementResourceHelper.getRowsAndSizeFromPayload(
-          payload,
-          isSelectQuery
+          queryId)));
+      MSQTaskReportPayload msqTaskReportPayload = 
jsonMapper.convertValue(payload, MSQTaskReportPayload.class);
+      Optional<List<PageInformation>> pageList = 
SqlStatementResourceHelper.populatePageList(
+          msqTaskReportPayload,
+          msqDestination
       );
-      return Optional.of(new ResultSetInformation(
-          rowsAndSize.orElse(new Pair<>(null, null)).lhs,
-          rowsAndSize.orElse(new Pair<>(null, null)).rhs,
-          null,
-          dataSource,
-          // only populate sample results in case a select query is successful
-          isSelectQuery ? 
SqlStatementResourceHelper.getResults(payload).orElse(null) : null,
-          ImmutableList.of(
-              new PageInformation(
-                  rowsAndSize.orElse(new Pair<>(null, null)).lhs,
-                  rowsAndSize.orElse(new Pair<>(null, null)).rhs,
-                  0
-              )
+
+      // getting the total number of rows, size from page information.
+      Long rows = 0L;
+      Long size = 0L;

Review Comment:
   ## Boxed variable is never null
   
   The variable 'size' is only assigned values of primitive type and is never 
'null', but it is declared with the boxed type 'Long'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5225)



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