| 1333 | } |
| 1334 | |
| 1335 | Status ImpalaServer::Execute(TQueryCtx* query_ctx, |
| 1336 | const shared_ptr<SessionState>& session_state, QueryHandle* query_handle, |
| 1337 | const TExecRequest* external_exec_request, const bool include_in_query_log) { |
| 1338 | PrepareQueryContext(query_ctx); |
| 1339 | ImpaladMetrics::IMPALA_SERVER_NUM_QUERIES->Increment(1L); |
| 1340 | |
| 1341 | // Redact the SQL stmt and update the query context |
| 1342 | string stmt = replace_all_copy(query_ctx->client_request.stmt, "\n", " "); |
| 1343 | Redact(&stmt); |
| 1344 | query_ctx->client_request.__set_redacted_stmt((const string) stmt); |
| 1345 | |
| 1346 | bool registered_query = false; |
| 1347 | Status status = ExecuteInternal(*query_ctx, external_exec_request, session_state, |
| 1348 | ®istered_query, query_handle); |
| 1349 | |
| 1350 | query_handle->query_driver()->IncludeInQueryLog(include_in_query_log); |
| 1351 | |
| 1352 | // Unregister query if it was registered and not yet finalized. |
| 1353 | if (!status.ok() && !query_handle->query_driver()->finalized()) { |
| 1354 | if (registered_query) { |
| 1355 | UnregisterQueryDiscardResult((*query_handle)->query_id(), &status); |
| 1356 | } else { |
| 1357 | query_handle->query_driver()->Abandon(); |
| 1358 | } |
| 1359 | } |
| 1360 | return status; |
| 1361 | } |
| 1362 | |
| 1363 | Status ImpalaServer::ExecuteInternal(const TQueryCtx& query_ctx, |
| 1364 | const TExecRequest* external_exec_request, |