(call *ast.CallExpr, inType super.Type)
| 1115 | } |
| 1116 | |
| 1117 | func (t *translator) maybeConvertAgg(call *ast.CallExpr, inType super.Type) (sem.Expr, super.Type) { |
| 1118 | name, ok := call.Func.(*ast.FuncNameExpr) |
| 1119 | if !ok { |
| 1120 | return nil, t.checker.unknown |
| 1121 | } |
| 1122 | nameLower := strings.ToLower(name.Name) |
| 1123 | if _, err := agg.NewPattern(nameLower, false, true); err != nil { |
| 1124 | return nil, t.checker.unknown |
| 1125 | } |
| 1126 | if err := function.CheckArgCount(len(call.Args), 0, 1); err != nil { |
| 1127 | if nameLower == "min" || nameLower == "max" { |
| 1128 | // min and max are special cases as they are also functions. If the |
| 1129 | // number of args is greater than 1 they're probably a function so do not |
| 1130 | // return an error. |
| 1131 | return nil, nil |
| 1132 | } |
| 1133 | t.error(call, err) |
| 1134 | return badExpr, t.checker.unknown |
| 1135 | } |
| 1136 | var e ast.Expr |
| 1137 | if len(call.Args) == 1 { |
| 1138 | e = call.Args[0] |
| 1139 | } |
| 1140 | return t.aggFunc(call, nameLower, e, nil, false, inType) |
| 1141 | } |
| 1142 | |
| 1143 | func (t *translator) aggFunc(n ast.Node, name string, arg ast.Expr, filter ast.Expr, distinct bool, inType super.Type) (sem.Expr, super.Type) { |
| 1144 | // If we are in the context of a having clause, re-expose the select schema |
no test coverage detected