InvisibleProgrammer commented on PR #6412:
URL: https://github.com/apache/hive/pull/6412#issuecomment-4291801704

   I wonder, how this solution behaves with a test case when we have a single 
connection and we execute multiple statements, one-by-one?
   
   Example test case:
   ```
     @Test
     public void testQueryTimeout() throws Exception {
       String udfName = SleepMsUDF.class.getName();
       Statement stmt1 = con.createStatement();
       stmt1.execute("create temporary function sleepMsUDF as '" + udfName + 
"'");
       stmt1.close();
       Statement stmt2 = con.createStatement();
       stmt2.execute("set hive.query.timeout.seconds=1s");
       stmt2.close();
       Statement stmt = con.createStatement();
   
       System.err.println("Executing query: ");
       try {
         // The test table has 500 rows, so total query time should be ~ 2500ms
         stmt.executeQuery("select sleepMsUDF(t1.under_col, 5) as u0, 
t1.under_col as u1, "
             + "t2.under_col as u2 from " + tableName + " t1 join " + tableName
             + " t2 on t1.under_col = t2.under_col");
         fail("Expecting SQLTimeoutException");
       } catch (SQLTimeoutException e) {
         assertNotNull(e);
         System.err.println(e.toString());
         assertEquals("Query timed out after 1 seconds", e.getMessage());
       } catch (SQLException e) {
         fail("Expecting SQLTimeoutException, but got SQLException: " + e);
         e.printStackTrace();
       }
   
       // Test a query where timeout does not kick in. Set it to 5s;
       // show tables should be faster than that
       stmt.setQueryTimeout(5);
       try {
         stmt.executeQuery("show tables");
       } catch (SQLException e) {
         fail("Unexpected SQLException: " + e);
         e.printStackTrace();
       }
       stmt.close();
     }
   ```
   


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