| 539 | }; |
| 540 | |
| 541 | static void buildTreeOffset( |
| 542 | const std::deque<ExplainPlan::Frame> & frames, |
| 543 | const ExplainPlan::Frame & current, |
| 544 | IQueryPlanStep::FormatSettings & settings_format, |
| 545 | const std::string & parent_tree_prefix = "", |
| 546 | bool is_last_child_plan = true) |
| 547 | { |
| 548 | if (frames.empty()) |
| 549 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Frames stack for building tree offset cannot be empty"); |
| 550 | |
| 551 | settings_format.header_prefix = parent_tree_prefix; |
| 552 | settings_format.detail_prefix = parent_tree_prefix; |
| 553 | |
| 554 | bool has_children = !current.node->children.empty() || !current.node->step->getChildPlans().empty(); |
| 555 | |
| 556 | if (frames.size() == 1) |
| 557 | { |
| 558 | if (!parent_tree_prefix.empty()) |
| 559 | { |
| 560 | settings_format.header_prefix += is_last_child_plan ? "└──" : "├──"; |
| 561 | settings_format.detail_prefix += is_last_child_plan ? " " : "│ "; |
| 562 | } |
| 563 | settings_format.detail_prefix += has_children ? "│ " : " "; |
| 564 | return; |
| 565 | } |
| 566 | |
| 567 | if (!parent_tree_prefix.empty()) |
| 568 | { |
| 569 | settings_format.header_prefix += is_last_child_plan ? " " : "│ "; |
| 570 | settings_format.detail_prefix += is_last_child_plan ? " " : "│ "; |
| 571 | } |
| 572 | |
| 573 | for (size_t i = 0; i < frames.size() - 2; ++i) |
| 574 | { |
| 575 | const auto & segment = frames[i + 1].is_last_child ? " " : "│ "; |
| 576 | settings_format.header_prefix += segment; |
| 577 | settings_format.detail_prefix += segment; |
| 578 | } |
| 579 | |
| 580 | settings_format.header_prefix += current.is_last_child ? "└──" : "├──"; |
| 581 | settings_format.detail_prefix += current.is_last_child ? " " : "│ "; |
| 582 | settings_format.detail_prefix += has_children ? "│ " : " "; |
| 583 | } |
| 584 | |
| 585 | static void buildIndentOffset(const std::deque<ExplainPlan::Frame> & frames, IQueryPlanStep::FormatSettings & settings_format, size_t indent_offset) |
| 586 | { |
no test coverage detected