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

Method groupBy

compiler/semantic/sql.go:665–686  ·  view source on GitHub ↗
(sch *selectScope, in []ast.Expr, inType super.Type)

Source from the content-addressed store, hash-verified

663}
664
665func (t *translator) groupBy(sch *selectScope, in []ast.Expr, inType super.Type) []exprloc {
666 var out []exprloc
667 for _, expr := range in {
668 var typ super.Type
669 var e sem.Expr
670 if colno, ok := isOrdinal(expr); ok {
671 if colno < 1 || colno > len(sch.columns) {
672 t.error(expr, fmt.Errorf("position %d is not in select list", colno))
673 typ = t.checker.unknown
674 } else {
675 save := sch.groupByLoc
676 sch.groupByLoc = expr
677 e, typ = t.expr(sch.columns[colno-1].astExpr, inType)
678 sch.groupByLoc = save
679 }
680 } else {
681 e, typ = t.expr(expr, inType)
682 }
683 out = append(out, exprloc{expr, e, typ})
684 }
685 return out
686}
687
688func isOrdinal(e ast.Expr) (int, bool) {
689 if e, ok := e.(*ast.Primitive); ok && e.Type == "int64" {

Callers 1

sqlSelectMethod · 0.95

Calls 3

exprMethod · 0.95
isOrdinalFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected