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)
| 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(). |
| 135 | func (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 | |
| 154 | func (t *translator) replaceGroupings(scope *selectScope, columns []column) { |
| 155 | for k, c := range columns { |
no test coverage detected