MCPcopy Create free account
hub / github.com/brimdata/super / formProjection

Method formProjection

compiler/semantic/sql.go:168–188  ·  view source on GitHub ↗
(scope *selectScope, in []ast.SQLAsExpr, inType super.Type)

Source from the content-addressed store, hash-verified

166}
167
168func (t *translator) formProjection(scope *selectScope, in []ast.SQLAsExpr, inType super.Type) []column {
169 var out []column
170 scores := make(map[string]int)
171 for _, as := range in {
172 if star, ok := as.Expr.(*ast.StarExpr); ok {
173 // expand * and table.* expressions
174 paths, err := scope.star(star, star.Table, nil)
175 if err != nil {
176 t.error(as, err)
177 }
178 for _, p := range paths {
179 typ := t.checker.this(star, p, inType)
180 out = append(out, column{name: dedup(scores, t.asName(as.Label, nil, p.Path)), semExpr: p, typ: typ, astExpr: as.Expr})
181 }
182 continue
183 }
184 lateral := as.Label != nil && as.Label.Name != ""
185 out = append(out, column{name: dedup(scores, t.asName(as.Label, as.Expr, nil)), astExpr: as.Expr, lateral: lateral})
186 }
187 return out
188}
189
190func (t *translator) asName(label *ast.ID, expr ast.Expr, path []string) string {
191 var name string

Callers 1

sqlSelectMethod · 0.95

Calls 5

asNameMethod · 0.95
dedupFunction · 0.85
starMethod · 0.65
thisMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected