(columns []column, grouped bool, seq sem.Seq)
| 217 | } |
| 218 | |
| 219 | func (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 | |
| 262 | func (t *translator) genAggregate(loc ast.Loc, scope *selectScope, seq sem.Seq) sem.Seq { |
| 263 | var aggCols []sem.Assignment |
no test coverage detected