diff --git service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java index 80a615d..e9f619a 100644 --- service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java +++ service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java @@ -249,7 +249,7 @@ private void runQuery() throws HiveSQLException { if (0 != response.getResponseCode()) { throw toSQLException("Error while processing statement", response); } - } catch (HiveSQLException e) { + } catch (Throwable e) { /** * If the operation was cancelled by another thread, or the execution timed out, Driver#run * may return a non-zero response code. We will simply return if the operation state is @@ -258,14 +258,15 @@ private void runQuery() throws HiveSQLException { if ((getStatus().getState() == OperationState.CANCELED) || (getStatus().getState() == OperationState.TIMEDOUT) || (getStatus().getState() == OperationState.CLOSED)) { + LOG.warn("Ignore exception in terminal state", e); return; - } else { - setState(OperationState.ERROR); - throw e; } - } catch (Throwable e) { setState(OperationState.ERROR); - throw new HiveSQLException("Error running query: " + e.toString(), e); + if (e instanceof HiveSQLException) { + throw (HiveSQLException) e; + } else { + throw new HiveSQLException("Error running query: " + e.toString(), e); + } } setState(OperationState.FINISHED); }