InvisibleProgrammer commented on code in PR #6412:
URL: https://github.com/apache/hive/pull/6412#discussion_r3150053112
##########
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java:
##########
@@ -398,20 +398,95 @@ private TGetOperationStatusResp waitForResultSetStatus()
throws SQLException {
return statusResp;
}
+ /**
+ * HIVE-28265: Prefer server error text (from {@code
TGetOperationStatusResp.errorMessage}) unless
+ * it is empty or the legacy "0 seconds" value; fall back to JDBC {@link
#setQueryTimeout(int)}
+ * or the URL-seeded {@code hive.query.timeout.seconds} on the connection.
+ */
+ 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();
+ final String fullErrMsg;
+ if (errMsg == null || errMsg.isEmpty()) {
+ fullErrMsg = QUERY_CANCELLED_MESSAGE;
+ } else {
+ fullErrMsg = QUERY_CANCELLED_MESSAGE + " " + errMsg;
+ }
+ return new SQLException(fullErrMsg, "01000");
+ }
+
+ /**
+ * One GetOperationStatus response: progress update, Thrift status check,
then terminal states.
+ * Extracted to keep {@link #waitForOperationToComplete()} smaller for
static analysis (Sonar).
Review Comment:
I don't think if comments like this line adding extra information. Like,
what if we switch from Sonar to an other tool? The logic is extracted. Great.
It is easier to read the code now. But providing that information maybe too
much.
--
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]