Helper for PlanToJson(), called only when the plan fragment's root data sink must be one of the following types: - table sink, - multi data sink, - merge sink. Plan nodes of the plan fragment will be listed as children of the root data sink.
| 1212 | // - merge sink. |
| 1213 | // Plan nodes of the plan fragment will be listed as children of the root data sink. |
| 1214 | void SinkToJsonHelper(const TDataSink& sink, |
| 1215 | const map<TPlanNodeId, TPlanNodeExecSummary>& summaries, |
| 1216 | vector<TPlanNode>::const_iterator* it, rapidjson::Document* document, Value* value) { |
| 1217 | Value label(sink.label, document->GetAllocator()); |
| 1218 | value->AddMember("label", label, document->GetAllocator()); |
| 1219 | |
| 1220 | string label_detail_str = ""; |
| 1221 | switch (sink.type) { |
| 1222 | case TDataSinkType::type::MERGE_SINK: |
| 1223 | case TDataSinkType::type::MULTI_DATA_SINK: |
| 1224 | label_detail_str = sink.child_data_sinks.at(0).label; |
| 1225 | for (std::size_t i = 1; i < sink.child_data_sinks.size(); ++i) { |
| 1226 | label_detail_str += ", "; |
| 1227 | label_detail_str += sink.child_data_sinks.at(i).label; |
| 1228 | } |
| 1229 | break; |
| 1230 | case TDataSinkType::type::TABLE_SINK: |
| 1231 | label_detail_str = to_string(sink.table_sink.action); |
| 1232 | break; |
| 1233 | default: |
| 1234 | // Should not call SinkToJsonHelper() with any other sink type. |
| 1235 | DCHECK(false) << "Invalid sink type: " << sink.type; |
| 1236 | } |
| 1237 | Value label_detail(label_detail_str, document->GetAllocator()); |
| 1238 | value->AddMember("label_detail", label_detail, document->GetAllocator()); |
| 1239 | |
| 1240 | map<TPlanNodeId, TPlanNodeExecSummary>::const_iterator summary_it = |
| 1241 | summaries.find(SINK_NODE_ID); |
| 1242 | if (summary_it != summaries.end()) { |
| 1243 | // Sometimes we don't have a summary for the sink, e.g.: |
| 1244 | // - Query was rejected by admission control |
| 1245 | // - CTAS query failed to create the target table, so the sink was never executed |
| 1246 | ExecStatsToJsonHelper(summary_it->second, document, value); |
| 1247 | } |
| 1248 | |
| 1249 | Value children(kArrayType); |
| 1250 | |
| 1251 | Value container(kObjectType); |
| 1252 | PlanToJsonHelper(summaries, it, document, &container); |
| 1253 | children.PushBack(container, document->GetAllocator()); |
| 1254 | |
| 1255 | value->AddMember("children", children, document->GetAllocator()); |
| 1256 | } |
| 1257 | |
| 1258 | } // unnamed namespace |
| 1259 |
no test coverage detected