MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / processPlanImpl

Function processPlanImpl

statement.go:669–703  ·  view source on GitHub ↗
(plan *pb.QueryPlan, withStats bool)

Source from the content-addressed store, hash-verified

667}
668
669func 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
705type ShowColumnsStatement struct {
706 Schema string

Callers 2

processPlanWithStatsFunction · 0.85
processPlanWithoutStatsFunction · 0.85

Calls 3

getMaxRelationalNodeIDFunction · 0.85
BuildQueryPlanTreeFunction · 0.85
RenderTreeWithStatsMethod · 0.80

Tested by

no test coverage detected