(plan *pb.QueryPlan, withStats bool)
| 667 | } |
| 668 | |
| 669 | func processPlanImpl(plan *pb.QueryPlan, withStats bool) (rows []Row, predicates []string, err error) { |
| 670 | planNodes := plan.GetPlanNodes() |
| 671 | maxWidthOfNodeID := len(fmt.Sprint(getMaxRelationalNodeID(plan))) |
| 672 | widthOfNodeIDWithIndicator := maxWidthOfNodeID + 1 |
| 673 | |
| 674 | tree := BuildQueryPlanTree(plan, 0) |
| 675 | |
| 676 | treeRows, err := tree.RenderTreeWithStats(planNodes) |
| 677 | if err != nil { |
| 678 | return nil, nil, err |
| 679 | } |
| 680 | for _, row := range treeRows { |
| 681 | var formattedID string |
| 682 | if len(row.Predicates) > 0 { |
| 683 | formattedID = fmt.Sprintf("%*s", widthOfNodeIDWithIndicator, "*"+fmt.Sprint(row.ID)) |
| 684 | } else { |
| 685 | formattedID = fmt.Sprintf("%*d", widthOfNodeIDWithIndicator, row.ID) |
| 686 | } |
| 687 | if withStats { |
| 688 | rows = append(rows, Row{[]string{formattedID, row.Text, row.RowsTotal, row.Execution, row.LatencyTotal}}) |
| 689 | } else { |
| 690 | rows = append(rows, Row{[]string{formattedID, row.Text}}) |
| 691 | } |
| 692 | for i, predicate := range row.Predicates { |
| 693 | var prefix string |
| 694 | if i == 0 { |
| 695 | prefix = fmt.Sprintf("%*d:", maxWidthOfNodeID, row.ID) |
| 696 | } else { |
| 697 | prefix = strings.Repeat(" ", maxWidthOfNodeID+1) |
| 698 | } |
| 699 | predicates = append(predicates, fmt.Sprintf("%s %s", prefix, predicate)) |
| 700 | } |
| 701 | } |
| 702 | return rows, predicates, nil |
| 703 | } |
| 704 | |
| 705 | type ShowColumnsStatement struct { |
| 706 | Schema string |
no test coverage detected