ashniku opened a new pull request, #6412:
URL: https://github.com/apache/hive/pull/6412

   
   
   ### What changes were proposed in this pull request?
   hive.query.timeout.seconds is enforced correctly, but Beeline/JDBC reported 
Query timed out after 0 seconds when Statement.setQueryTimeout was not used.
   
   This PR:
   
   1. **SQLOperation (HiveServer2)**
   Before cancel(OperationState.TIMEDOUT), set a HiveSQLException whose message 
is Query timed out after <N> seconds, using the effective operation timeout 
(<N> is the same value used to schedule the cancel). GetOperationStatus then 
exposes the right text via operationException.
   For async execution, do not call setOperationException from the background 
thread if the operation is already TIMEDOUT, so the timeout message is not 
overwritten.
   
   2. **HiveStatement (JDBC)**
   On TIMEDOUT_STATE, prefer the server errorMessage. If it is missing or 
clearly wrong (contains after 0 seconds), build the client message from 
Statement query timeout or from the last SET hive.query.timeout.seconds=... 
value tracked on HiveConnection. SET is detected with a regex find() so 
assignments can appear inside a longer script (last match wins).
   
   3. **HiveConnection**
   Stores the last parsed hive.query.timeout.seconds from a successful SET for 
use in the timeout message when needed.
   
   4. **Tests**
   
     ==> testQueryTimeoutMessageUsesHiveConf: session SET 
hive.query.timeout.seconds=1s, no setQueryTimeout, slow query via existing 
SleepMsUDF — expects SQLTimeoutException and message not claiming after 0 
seconds, and containing 1.
     ==> testQueryTimeout: same checks for the existing setQueryTimeout(1) path.
   
   -->
   
   
   ### Why are the changes needed?
   <!--
   The server already applies hive.query.timeout.seconds, but the JDBC client 
formatted SQLTimeoutException using only the JDBC queryTimeout field (default 0 
unless Statement.setQueryTimeout is called). That produced “after 0 seconds” 
even when the session timeout was 1s, 5s, etc. The fix aligns the message with 
the actual timeout (server-authoritative when present; sensible client 
fallbacks when not).
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Yes. For HiveServer2 clients over JDBC/Beeline, when a query is cancelled 
with TIMEDOUT, the error message now reflects the effective timeout in seconds 
(e.g. Query timed out after 5 seconds after SET hive.query.timeout.seconds=5s) 
instead of Query timed out after 0 seconds in the common case where only the 
session variable was set.
   -->
   
   ### How was this patch tested?
   <!--
   1. mvn -pl jdbc,service -am -DskipTests compile (and/or full hive-unit / 
TestJdbcDriver2 as CI runs).
   
   2. New/adjusted tests in 
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (see 
testQueryTimeoutMessageUsesHiveConf and testQueryTimeout).
   -->
   


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