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

Method emitProjection

compiler/semantic/sql.go:219–260  ·  view source on GitHub ↗
(columns []column, grouped bool, seq sem.Seq)

Source from the content-addressed store, hash-verified

217}
218
219func (t *translator) emitProjection(columns []column, grouped bool, seq sem.Seq) (sem.Seq, *staticTable) {
220 if len(columns) == 0 {
221 return seq, nil
222 }
223 var outs []sem.RecordElem
224 var fields []super.Field
225 for _, c := range columns {
226 outs = append(outs, &sem.FieldElem{
227 Node: c.astExpr,
228 Name: c.name,
229 Value: c.semExpr,
230 })
231 fields = append(fields, super.NewField(c.name, c.typ))
232 }
233 var in string
234 if grouped {
235 in = "g"
236 } else {
237 in = "in"
238 }
239 loc := columns[0].astExpr //XXX
240 e := &sem.RecordExpr{
241 Node: loc,
242 Elems: []sem.RecordElem{
243 &sem.FieldElem{
244 Node: loc,
245 Name: in,
246 Value: sem.NewThis(loc, field.Path{in}),
247 },
248 &sem.FieldElem{
249 Node: loc,
250 Name: "out",
251 Value: &sem.RecordExpr{
252 Node: loc,
253 Elems: outs,
254 },
255 },
256 },
257 }
258 outType := t.sctx.MustLookupTypeRecord(fields)
259 return append(seq, sem.NewValues(loc, e)), &staticTable{typ: outType}
260}
261
262func (t *translator) genAggregate(loc ast.Loc, scope *selectScope, seq sem.Seq) sem.Seq {
263 var aggCols []sem.Assignment

Callers 1

sqlSelectMethod · 0.95

Calls 4

NewFieldFunction · 0.92
NewThisFunction · 0.92
NewValuesFunction · 0.92
MustLookupTypeRecordMethod · 0.80

Tested by

no test coverage detected