deniskuzZ commented on code in PR #5854:
URL: https://github.com/apache/hive/pull/5854#discussion_r2139771008


##########
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/reexec/TestReExecuteKilledTezAMQueryPlugin.java:
##########
@@ -195,4 +201,32 @@ private void killAMForQueryId(String queryId) throws 
Exception {
       }
     }
   }
+
+  boolean isQueryRunning(String queryId, Connection conn) throws Exception {
+    boolean queryRunningInYarn = false;
+    boolean hiveRunning = false;
+
+    // Check YARN state
+    List<ApplicationReport> applicationReports = yarnClient.getApplications();
+    for (ApplicationReport ar : applicationReports) {
+      if (ar.getApplicationTags().contains(queryId) &&
+              ar.getYarnApplicationState() == YarnApplicationState.RUNNING) {
+        queryRunningInYarn = true;
+        break;
+      }
+    }
+    // check if the DAG is also started
+    if (queryRunningInYarn) {
+      try (Statement s = conn.createStatement();
+           ResultSet rs = s.executeQuery(
+                   "SELECT STATE FROM SYS.QUERY WHERE QUERY_ID='" + queryId + 
"'")) {
+        if (rs.next()) {
+          hiveRunning = "RUNNING".equalsIgnoreCase(rs.getString(1));
+        }
+      } catch (Exception e) {
+        LOG.warn("Exception when checking hive state", e);
+      }
+    }
+    return queryRunningInYarn && hiveRunning;

Review Comment:
   minor: `hiveRunning` already incorporates the `queryRunningInYarn` flag 
since it's inside the if block



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to