| 272 | } |
| 273 | |
| 274 | static void explainStep(const IQueryPlanStep & step, JSONBuilder::JSONMap & map, const ExplainPlanOptions & options) |
| 275 | { |
| 276 | map.add("Node Type", step.getName()); |
| 277 | map.add("Node Id", step.getUniqID()); |
| 278 | |
| 279 | if (options.description) |
| 280 | { |
| 281 | const auto & description = step.getStepDescription(); |
| 282 | if (!description.empty()) |
| 283 | map.add("Description", description); |
| 284 | } |
| 285 | |
| 286 | const auto dump_column = [](JSONBuilder::JSONArray & header_array, const ColumnWithTypeAndName & column) |
| 287 | { |
| 288 | auto column_map = std::make_unique<JSONBuilder::JSONMap>(); |
| 289 | column_map->add("Name", column.name); |
| 290 | if (column.type) |
| 291 | column_map->add("Type", column.type->getName()); |
| 292 | header_array.add(std::move(column_map)); |
| 293 | }; |
| 294 | |
| 295 | if (options.header && step.hasOutputHeader()) |
| 296 | { |
| 297 | auto header_array = std::make_unique<JSONBuilder::JSONArray>(); |
| 298 | |
| 299 | for (const auto & output_column : *step.getOutputHeader()) |
| 300 | dump_column(*header_array, output_column); |
| 301 | |
| 302 | map.add("Header", std::move(header_array)); |
| 303 | } |
| 304 | |
| 305 | if (options.input_headers && !step.getInputHeaders().empty()) |
| 306 | { |
| 307 | auto input_headers_array = std::make_unique<JSONBuilder::JSONArray>(); |
| 308 | |
| 309 | for (const auto & input_header : step.getInputHeaders()) |
| 310 | { |
| 311 | auto header_array = std::make_unique<JSONBuilder::JSONArray>(); |
| 312 | |
| 313 | for (const auto & input_column : *input_header) |
| 314 | dump_column(*header_array, input_column); |
| 315 | |
| 316 | input_headers_array->add(std::move(header_array)); |
| 317 | } |
| 318 | |
| 319 | map.add("Input Headers", std::move(input_headers_array)); |
| 320 | } |
| 321 | |
| 322 | if (options.actions) |
| 323 | step.describeActions(map); |
| 324 | |
| 325 | if (options.indexes) |
| 326 | step.describeIndexes(map); |
| 327 | |
| 328 | if (options.projections) |
| 329 | step.describeProjections(map); |
| 330 | } |
| 331 |
no test coverage detected