InvisibleProgrammer commented on code in PR #6412:
URL: https://github.com/apache/hive/pull/6412#discussion_r3181826233


##########
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java:
##########
@@ -398,20 +398,95 @@ private TGetOperationStatusResp waitForResultSetStatus() 
throws SQLException {
     return statusResp;
   }
 
+  /**
+   * Prefers the server error text from {@code 
TGetOperationStatusResp.errorMessage} when it is
+   * present and plausible; falls back to a locally derived message using
+   * {@link #setQueryTimeout(int)} or the URL-seeded {@code 
hive.query.timeout.seconds} value.
+   */
+  private String sqlTimeoutMessageForTimedOutState(String serverMessage) {
+    if (!needsLocalTimeoutMessageForTimedOut(serverMessage)) {
+      return serverMessage;
+    }
+    long effectiveSec = resolveEffectiveTimeoutSecondsForMessage();
+    if (effectiveSec > 0) {
+      return "Query timed out after " + effectiveSec + " seconds";
+    }
+    return "Query timed out";
+  }
+
+  private boolean needsLocalTimeoutMessageForTimedOut(String timeoutMsg) {
+    return StringUtils.isBlank(timeoutMsg)
+        || StringUtils.containsIgnoreCase(timeoutMsg, "after 0 seconds");
+  }
+
+  private long resolveEffectiveTimeoutSecondsForMessage() {
+    if (queryTimeout > 0) {
+      return queryTimeout;
+    }
+    long tracked = connection.getSessionQueryTimeoutSeconds();
+    if (tracked > 0) {
+      return tracked;
+    }
+    return 0L;
+  }
+
+  private SQLException sqlExceptionForCanceledState(TGetOperationStatusResp 
statusResp) {
+    final String errMsg = statusResp.getErrorMessage();

Review Comment:
   I think that comment was actually useful:
   ```
   // 01000 -> warning
   ```
   



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