MCPcopy Create free account
hub / github.com/araddon/qlbridge / WalkSelect

Method WalkSelect

plan/planner_select.go:27–141  ·  view source on GitHub ↗

WalkSelect walk a select statement filling out plan.

(p *Select)

Source from the content-addressed store, hash-verified

25
26// WalkSelect walk a select statement filling out plan.
27func (m *PlannerDefault) WalkSelect(p *Select) error {
28
29 // u.Debugf("VisitSelect ctx:%p %+v", p.Ctx, p.Stmt)
30
31 needsFinalProject := true
32
33 if len(p.Stmt.From) == 0 {
34
35 return m.WalkLiteralQuery(p)
36
37 } else if len(p.Stmt.From) == 1 {
38
39 p.Stmt.From[0].Source = p.Stmt // TODO: move to a Finalize() in query parser/planner
40
41 srcPlan, err := NewSource(m.Ctx, p.Stmt.From[0], true)
42 if err != nil {
43 return err
44 }
45 p.From = append(p.From, srcPlan)
46 p.Add(srcPlan)
47
48 err = m.Planner.WalkSourceSelect(srcPlan)
49 if err != nil {
50 return err
51 }
52
53 if srcPlan.Complete && !needsFinalProjection(p.Stmt) {
54 goto finalProjection
55 }
56
57 } else {
58
59 var prevSource *Source
60 var prevTask Task
61
62 for i, from := range p.Stmt.From {
63
64 // Need to rewrite the From statement to ensure all fields necessary to support
65 // joins, wheres, etc exist but is standalone query
66 from.Rewrite(p.Stmt)
67 srcPlan, err := NewSource(m.Ctx, from, false)
68 if err != nil {
69 return nil
70 }
71 err = m.Planner.WalkSourceSelect(srcPlan)
72 if err != nil {
73 u.Errorf("Could not visitsubselect %v %s", err, from)
74 return err
75 }
76
77 // now fold into previous task
78 if i != 0 {
79 from.Seekable = true
80 // fold this source into previous
81 curMergeTask := NewJoinMerge(prevTask, srcPlan, prevSource.Stmt, srcPlan.Stmt)
82 prevTask = curMergeTask
83 } else {
84 prevTask = srcPlan

Callers

nothing calls this directly

Calls 15

WalkLiteralQueryMethod · 0.95
WalkProjectionFinalMethod · 0.95
needsFinalProjectionFunction · 0.85
NewJoinMergeFunction · 0.85
ErrorfMethod · 0.80
IsAggQueryMethod · 0.80
NewSourceFunction · 0.70
NewWhereFunction · 0.70
NewGroupByFunction · 0.70
NewHavingFunction · 0.70
NewOrderFunction · 0.70
NewProjectionFinalFunction · 0.70

Tested by

no test coverage detected