MCPcopy Create free account
hub / github.com/dolthub/doltgresql / compileAggFunction

Function compileAggFunction

server/functions/framework/catalog.go:195–215  ·  view source on GitHub ↗

compileNonOperatorFunction creates a CompiledFunction for each overload of the given function.

(funcName string, overloads []AggregateFunctionInterface)

Source from the content-addressed store, hash-verified

193
194// compileNonOperatorFunction creates a CompiledFunction for each overload of the given function.
195func 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.
218func compileFunctions() {

Callers 1

compileAggsFunction · 0.85

Calls 3

AddMethod · 0.95
NewOverloadsFunction · 0.85

Tested by

no test coverage detected