compileNonOperatorFunction creates a CompiledFunction for each overload of the given function.
(funcName string, overloads []AggregateFunctionInterface)
| 193 | |
| 194 | // compileNonOperatorFunction creates a CompiledFunction for each overload of the given function. |
| 195 | func compileAggFunction(funcName string, overloads []AggregateFunctionInterface) { |
| 196 | var newBuffer NewBufferFn |
| 197 | overloadTree := NewOverloads() |
| 198 | for _, functionOverload := range overloads { |
| 199 | newBuffer = functionOverload.NewBuffer |
| 200 | if err := overloadTree.Add(functionOverload); err != nil { |
| 201 | panic(err) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // Store the compiled function into the engine's built-in functions |
| 206 | // TODO: don't do this, use an actual contract for communicating these functions to the engine catalog |
| 207 | createFunc := func(ctx *sql.Context, params ...sql.Expression) (sql.Expression, error) { |
| 208 | return NewCompiledAggregateFunction(ctx, funcName, params, overloadTree, newBuffer), nil |
| 209 | } |
| 210 | function.BuiltIns = append(function.BuiltIns, sql.FunctionN{ |
| 211 | Name: funcName, |
| 212 | Fn: createFunc, |
| 213 | }) |
| 214 | compiledCatalog[funcName] = createFunc |
| 215 | } |
| 216 | |
| 217 | // compileFunctions creates a CompiledFunction for each overload of each function in the catalog. |
| 218 | func compileFunctions() { |
no test coverage detected