| 1707 | } |
| 1708 | |
| 1709 | Status ImpalaServer::StoreExecutionStats(const QueryHandle& query_handle) { |
| 1710 | if (!query_handle->query_options().store_hbo_stats) { |
| 1711 | return Status::OK(); |
| 1712 | } |
| 1713 | if (query_handle->exec_state() != ClientRequestState::ExecState::FINISHED) { |
| 1714 | VLOG_QUERY << "Skip execution stats for query " << PrintId(query_handle->query_id()) |
| 1715 | << " since query state is " |
| 1716 | << ClientRequestState::ExecStateToString(query_handle->exec_state()); |
| 1717 | return Status::OK(); |
| 1718 | } |
| 1719 | |
| 1720 | const TExecRequest& exec_req = query_handle->exec_request(); |
| 1721 | if (query_handle->GetCoordinator() == nullptr) { |
| 1722 | LOG(ERROR) << "ExecSummary not found for HBO!"; |
| 1723 | return Status("ExecSummary not found for HBO"); |
| 1724 | } |
| 1725 | |
| 1726 | TExecSummary summary; |
| 1727 | query_handle->GetCoordinator()->GetTExecSummary(&summary); |
| 1728 | map<TPlanNodeId, TPlanNodeExecSummary> exec_summaries; |
| 1729 | for (const TPlanNodeExecSummary& s : summary.nodes) { |
| 1730 | exec_summaries[s.node_id] = s; |
| 1731 | } |
| 1732 | |
| 1733 | const auto& effective_filter_ids_to_node_ids = |
| 1734 | query_handle->GetCoordinator()->GetEffectiveFilterTargets(); |
| 1735 | |
| 1736 | THistoricalStatsUpdate history_stats; |
| 1737 | vector<const TPlanNode*> nodes_with_hbo_keys; |
| 1738 | GetPlanNodesWithHboKeys(exec_req, &nodes_with_hbo_keys); |
| 1739 | for (const TPlanNode* p : nodes_with_hbo_keys) { |
| 1740 | // Skip nodes if runtime filters have filtered some rows. The output cardinality |
| 1741 | // depends on when the runtime filters arrive, which is unreliable. |
| 1742 | if (HasEffectiveRuntimeFilter(*p, effective_filter_ids_to_node_ids)) { |
| 1743 | LOG(INFO) << "Skip execution stats of " << p->label |
| 1744 | << " since it has effective runtime filters"; |
| 1745 | continue; |
| 1746 | } |
| 1747 | |
| 1748 | // TODO: store the cumulative TExecStats instead of just cardinality |
| 1749 | int64_t cardinality = 0; |
| 1750 | if (!GetCardinalityIfComplete(exec_summaries[p->node_id], *p, &cardinality)) { |
| 1751 | continue; |
| 1752 | } |
| 1753 | AppendHboPlanNodeRuns(query_handle->query_id(), *p, cardinality, &history_stats); |
| 1754 | } |
| 1755 | if (history_stats.plan_node_runs.empty()) return Status::OK(); |
| 1756 | history_stats.__isset.plan_node_runs = true; |
| 1757 | LOG(INFO) << "Storing history stats for query " << PrintId(query_handle->query_id()); |
| 1758 | return exec_env_->frontend()->StoreExecStats(history_stats); |
| 1759 | } |
| 1760 | |
| 1761 | Status ImpalaServer::UnregisterQuery( |
| 1762 | const TUniqueId& query_id, const Status* cause, bool interrupted) { |
nothing calls this directly
no test coverage detected