Skip to content

Commit 4e1eb25

Browse files
Alex Behmjenkins
Alex Behm
authored and
jenkins
committed
IMPALA-762: Add the query status to Beeswax::get_log() and pick it up in the Impala shell.
COMPUTE STATS is an async DDL command. When COMPUTE STATS fails it will set the query status of the QueryExecState properly, but the original Beeswax::query() RPC won't throw. The Impala shell sometimes did not pick up and display the query status because no RPC actually threw. To fix this, I modified Beeswax::get_log() to include the query status if it is not ok. The shell looks for a special prefix to distinguish the query status from the runtime state error log. Change-Id: I0d9dbf0801629a37de22ea4ebb6d2e5d53b836ef Reviewed-on: http://gerrit.ent.cloudera.com:8080/1899 Reviewed-by: Alex Behm <[email protected]> Tested-by: jenkins
1 parent f7df0cb commit 4e1eb25

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

be/src/service/impala-beeswax-server.cc

+10-1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void ImpalaServer::query(QueryHandle& query_handle, const Query& query) {
187187
// us to advance query state to FINISHED or EXCEPTION
188188
Thread wait_thread(
189189
"impala-server", "wait-thread", &ImpalaServer::Wait, this, exec_state);
190+
RAISE_IF_ERROR(exec_state->query_status(), SQLSTATE_GENERAL_ERROR);
190191
}
191192

192193
void ImpalaServer::executeAndWait(QueryHandle& query_handle, const Query& query,
@@ -379,8 +380,16 @@ void ImpalaServer::get_log(string& log, const LogContextId& context) {
379380
LOG(ERROR) << str.str();
380381
return;
381382
}
383+
stringstream error_log_ss;
384+
// If the query status is !ok, include the status error message at the top of the log.
385+
if (!exec_state->query_status().ok()) {
386+
error_log_ss << exec_state->query_status().GetErrorMsg();
387+
log = error_log_ss.str();
388+
}
382389
if (exec_state->coord() != NULL) {
383-
log = exec_state->coord()->GetErrorLog();
390+
if (!exec_state->query_status().ok()) error_log_ss << "\n\n";
391+
error_log_ss << exec_state->coord()->GetErrorLog();
392+
log = error_log_ss.str();
384393
}
385394
}
386395

shell/impala_shell.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ def __execute_query(self, query, is_insert=False):
621621
self.__print_error_log()
622622
break
623623
elif query_state == self.query_state["EXCEPTION"]:
624-
print_to_stderr('Query aborted.')
625624
if self.connected:
626625
self.__print_error_log()
627626
# Close the query handle even if it's an insert.
@@ -768,8 +767,10 @@ def __print_error_log(self):
768767
rpc_result = self.__do_rpc(
769768
lambda: self.imp_service.get_log(self.last_query_handle.log_context))
770769
log, status = rpc_result.get_results()
770+
if status != RpcStatus.OK:
771+
print_to_stderr("Failed to get error log: %s" % status)
771772
if log and log.strip():
772-
print_to_stderr("\nERRORS ENCOUNTERED DURING EXECUTION: %s" % log)
773+
print_to_stderr("ERRORS: %s" % log)
773774

774775
def do_alter(self, args):
775776
return self.__execute_query(self.__create_beeswax_query("alter %s" % args))

tests/shell/test_shell_commandline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_completed_query_errors(self):
149149
args = ('-q "set abort_on_error=false;'
150150
' select count(*) from functional_seq_snap.bad_seq_snap" --quiet')
151151
result = run_impala_shell_cmd(args)
152-
assert 'ERRORS ENCOUNTERED DURING EXECUTION:' in result.stderr
152+
assert 'ERRORS:' in result.stderr
153153
assert 'Bad synchronization marker' in result.stderr
154154
assert 'Expected: ' in result.stderr
155155
assert 'Actual: ' in result.stderr

0 commit comments

Comments
 (0)