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

Method groupedExpr

compiler/semantic/sql.go:135–152  ·  view source on GitHub ↗

groupedExpr translates e in the context of any grouping expressions where we translate any matching expression to its aggregate tmp variable and flag an error if we encounter un-matched references to the input table. When the select scope isn't an agg, this is like a normal t.expr().

(scope *selectScope, e ast.Expr, inType super.Type)

Source from the content-addressed store, hash-verified

133// flag an error if we encounter un-matched references to the input table.
134// When the select scope isn't an agg, this is like a normal t.expr().
135func (t *translator) groupedExpr(scope *selectScope, e ast.Expr, inType super.Type) (sem.Expr, super.Type) {
136 if e != nil {
137 if !scope.isGrouped() {
138 return t.expr(e, inType)
139 }
140 save := scope.grouped
141 defer func() {
142 scope.grouped = save
143 }()
144 scope.grouped = true
145 expr, typ := t.expr(e, inType)
146 if out, ok := replaceGroupings(t, expr, scope.groupings); ok {
147 // Note that the replacements do not change the type here...
148 return out, typ
149 }
150 }
151 return nil, nil
152}
153
154func (t *translator) replaceGroupings(scope *selectScope, columns []column) {
155 for k, c := range columns {

Callers 2

sqlSelectMethod · 0.95
sortExprMethod · 0.95

Calls 3

exprMethod · 0.95
replaceGroupingsFunction · 0.85
isGroupedMethod · 0.80

Tested by

no test coverage detected