Skip to content

Commit b3a4c87

Browse files
authored
Merge pull request #2845 from dolthub/daylon/function-provider
Added external function provider
2 parents c631117 + b7600cb commit b3a4c87

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sql/analyzer/catalog.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,19 @@ func (c *Catalog) RegisterFunction(ctx *sql.Context, fns ...sql.Function) {
343343
}
344344
}
345345

346+
// ExternalFunctionProvider is a function provider that may be set by an integrator for cases that the DatabaseProvider
347+
// does not implement the necessary function provider logic (and we need more than the built-in functions). This is used
348+
// by Catalog to check for functions if it is non-nil.
349+
var ExternalFunctionProvider sql.FunctionProvider
350+
346351
// Function returns the function with the name given, or false if it doesn't exist.
347352
func (c *Catalog) Function(ctx *sql.Context, name string) (sql.Function, bool) {
353+
if ExternalFunctionProvider != nil {
354+
f, ok := ExternalFunctionProvider.Function(ctx, name)
355+
if ok {
356+
return f, true
357+
}
358+
}
348359
if fp, ok := c.DbProvider.(sql.FunctionProvider); ok {
349360
f, ok := fp.Function(ctx, name)
350361
if ok {

0 commit comments

Comments
 (0)