MCPcopy Create free account
hub / github.com/apache/impala / QuerySummaryHandler

Method QuerySummaryHandler

be/src/service/impala-http-handler.cc:1359–1465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359void ImpalaHttpHandler::QuerySummaryHandler(bool include_json_plan, bool include_summary,
1360 const Webserver::WebRequest& req, Document* document) {
1361 TUniqueId query_id;
1362 Status status = ParseIdFromRequest(req, &query_id, "query_id");
1363 Value query_id_val(PrintId(query_id), document->GetAllocator());
1364 document->AddMember("query_id", query_id_val, document->GetAllocator());
1365 if (!status.ok()) {
1366 // Redact the error message, it may contain part or all of the query.
1367 Value json_error(RedactCopy(status.GetDetail()), document->GetAllocator());
1368 document->AddMember("error", json_error, document->GetAllocator());
1369 return;
1370 }
1371
1372 shared_ptr<QueryStateRecord> query_record = nullptr;
1373 TExecSummary summary;
1374 string stmt;
1375 string plan;
1376 Status query_status;
1377 bool inflight = false;
1378 vector<TPlanFragment> fragments;
1379
1380 // Search the in-flight queries first, followed by the archived ones.
1381 {
1382 QueryHandle query_handle;
1383 status = server_->GetQueryHandle(query_id, &query_handle);
1384 if (status.ok()) {
1385 inflight = true;
1386 query_record = make_shared<QueryStateRecord>(*query_handle);
1387 // If the query plan isn't generated, avoid waiting for the request
1388 // state lock to be acquired, since it could potentially be an expensive
1389 // call, if the table Catalog metadata loading is in progress. Instead
1390 // update the caller that the plan information is unavailable.
1391 if (query_handle->exec_state() == ClientRequestState::ExecState::INITIALIZED) {
1392 document->AddMember(
1393 "plan_metadata_unavailable", "true", document->GetAllocator());
1394 return;
1395 }
1396 lock_guard<mutex> l(*(*query_handle).lock());
1397 query_status = query_handle->query_status();
1398 stmt = query_handle->sql_stmt();
1399 const TExecRequest& exec_request = query_handle->exec_request();
1400 plan = exec_request.query_exec_request.query_plan;
1401 if ((include_json_plan || include_summary)
1402 && query_handle->GetCoordinator() != nullptr) {
1403 query_handle->GetCoordinator()->GetTExecSummary(&summary);
1404 }
1405 if (include_json_plan) {
1406 for (const TPlanExecInfo& plan_exec_info:
1407 exec_request.query_exec_request.plan_exec_info) {
1408 for (const TPlanFragment& fragment: plan_exec_info.fragments) {
1409 fragments.push_back(fragment);
1410 }
1411 }
1412 }
1413 }
1414 }
1415
1416 if (!inflight) {

Callers 1

RegisterHandlersMethod · 0.95

Calls 15

ParseIdFromRequestFunction · 0.85
PrintIdFunction · 0.85
RedactCopyFunction · 0.85
SubstituteFunction · 0.85
PrintExecSummaryFunction · 0.85
GetDetailMethod · 0.80
GetQueryHandleMethod · 0.80
exec_stateMethod · 0.80
sql_stmtMethod · 0.80
GetCoordinatorMethod · 0.80
GetTExecSummaryMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected