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

Method loadFinal

plan/projection.go:90–146  ·  view source on GitHub ↗
(ctx *Context, isFinal bool)

Source from the content-addressed store, hash-verified

88}
89
90func (m *Projection) loadFinal(ctx *Context, isFinal bool) error {
91
92 //u.Debugf("creating plan.Projection final %s", m.Stmt.String())
93
94 m.Proj = rel.NewProjection()
95
96 for _, from := range m.Stmt.From {
97
98 fromName := strings.ToLower(from.SourceName())
99 tbl, err := ctx.Schema.Table(fromName)
100 if err != nil {
101 u.Errorf("could not get table: %v", err)
102 return err
103 } else if tbl == nil {
104 u.Errorf("unexepcted nil table? %v", from.Name)
105 return fmt.Errorf("Table not found %q", from.Name)
106 } else {
107
108 //u.Debugf("getting cols? %v cols=%v", from.ColumnPositions())
109 for _, col := range from.Source.Columns {
110 //_, right, _ := col.LeftRight()
111 //u.Infof("col %s", col)
112 if col.Star {
113 for _, f := range tbl.Fields {
114 m.Proj.AddColumnShort(f.Name, f.ValueType())
115 }
116 } else {
117 if schemaCol, ok := tbl.FieldMap[col.SourceField]; ok {
118 if isFinal {
119 if col.InFinalProjection() {
120 //u.Debugf("in plan final %s", col.As)
121 m.Proj.AddColumnShort(col.As, schemaCol.ValueType())
122 }
123 } else {
124 //u.Debugf("not final %s", col.As)
125 m.Proj.AddColumnShort(col.As, schemaCol.ValueType())
126 }
127 //u.Debugf("projection: %p add col: %v %v", m.Proj, col.As, schemaCol.Type.String())
128 } else {
129 //u.Infof("schema col not found: final?%v col: %#v InFinal?%v", isFinal, col, col.InFinalProjection())
130 if isFinal {
131 if col.InFinalProjection() {
132 m.Proj.AddColumnShort(col.As, value.StringType)
133 } else {
134 u.Warnf("not adding to projection? %s", col)
135 }
136 } else {
137 m.Proj.AddColumnShort(col.As, value.StringType)
138 }
139 }
140 }
141
142 }
143 }
144 }
145 return nil
146}
147

Callers 1

NewProjectionFinalFunction · 0.95

Calls 7

NewProjectionFunction · 0.92
ErrorfMethod · 0.80
AddColumnShortMethod · 0.80
ValueTypeMethod · 0.80
InFinalProjectionMethod · 0.80
TableMethod · 0.65
SourceNameMethod · 0.45

Tested by

no test coverage detected