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

Function addIntoProjection

rel/sql_rewrite.go:138–160  ·  view source on GitHub ↗
(sel *SqlSelect, newCols []string)

Source from the content-addressed store, hash-verified

136 addIntoProjection(sel, colsToAdd)
137}
138func addIntoProjection(sel *SqlSelect, newCols []string) {
139 notExists := make(map[string]bool)
140 for _, colName := range newCols {
141 colName = strings.ToLower(colName)
142 found := false
143 for _, c := range sel.Columns {
144 if c.SourceField == colName {
145 // already in projection
146 found = true
147 break
148 }
149 }
150 if !found {
151 notExists[colName] = true
152 if colName == "*" {
153 sel.AddColumn(Column{Star: true})
154 } else {
155 nc := NewColumn(colName)
156 sel.AddColumn(*nc)
157 }
158 }
159 }
160}
161func rewriteWhere(stmt *SqlSelect, from *SqlSource, node expr.Node, cols Columns) (expr.Node, Columns) {
162 //u.Debugf("rewrite where %s", node)
163 switch nt := node.(type) {

Callers 2

RewriteSelectFunction · 0.85
rewriteIntoProjectionFunction · 0.85

Calls 2

NewColumnFunction · 0.85
AddColumnMethod · 0.65

Tested by

no test coverage detected