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

Method QueryAiGenerateAnalysisHandler

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

Source from the content-addressed store, hash-verified

453}
454
455void ImpalaHttpHandler::QueryAiGenerateAnalysisHandler(const Webserver::WebRequest& req,
456 Document* document) {
457 auto set_error = [&](const string& error_msg) {
458 Value error(error_msg.c_str(), document->GetAllocator());
459 document->AddMember("error", error, document->GetAllocator());
460 };
461
462 TUniqueId unique_id;
463 Status status = ParseIdFromRequest(req, &unique_id, "query_id");
464 if (!status.ok()) return set_error(status.GetDetail());
465
466 ImpalaServer::RuntimeProfileOutput runtime_profile;
467 Document profile_doc;
468 profile_doc.SetObject();
469 runtime_profile.json_output = &profile_doc;
470 status = server_->GetRuntimeProfileOutput(
471 unique_id, "", TRuntimeProfileFormat::JSON, &runtime_profile);
472 if (!status.ok()) return set_error(status.GetDetail());
473
474 const Value* profile_json = &profile_doc;
475 if (profile_doc.HasMember("contents")) profile_json = &profile_doc["contents"];
476
477 string analysis;
478 status = GenerateAiAnalysisFromProfile(*profile_json, &analysis);
479 if (!status.ok()) return set_error(status.GetDetail());
480
481 Value query_id(PrintId(unique_id), document->GetAllocator());
482 document->AddMember("query_id", query_id, document->GetAllocator());
483 Value analysis_value(analysis, document->GetAllocator());
484 document->AddMember("analysis", analysis_value, document->GetAllocator());
485 document->AddMember("status", rapidjson::StringRef("OK"), document->GetAllocator());
486}
487
488void ImpalaHttpHandler::AddQueryRecordTips(Document* document) {
489 document->AddMember("tips_query_id", "Unique ID of the query, click ID to jump to the "

Callers

nothing calls this directly

Calls 7

ParseIdFromRequestFunction · 0.85
PrintIdFunction · 0.85
GetDetailMethod · 0.80
AddMemberMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected