Skip to content

Commit

Permalink
opt: remove Metadata.AllUserDefinedFunctions
Browse files Browse the repository at this point in the history
The metadata method `AllUserDefinedFunctions` has been replaced with a
new function `HasUserDefinedFunctions` which provides a simpler API
without exposing the underlying UDF dependency map. The map is still
available outside of the opt package via the `TestingUDFDeps` method
which is designed for testing use only.

Release note: None
  • Loading branch information
mgartner committed Jul 27, 2023
1 parent 400105c commit a6a2ccc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/explain_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (b *stmtBundleBuilder) addEnv(ctx context.Context) {
if err := c.PrintCreateEnum(&buf, b.flags.RedactValues); err != nil {
b.printError(fmt.Sprintf("-- error getting schema for enums: %v", err), &buf)
}
if len(mem.Metadata().AllUserDefinedFunctions()) != 0 {
if mem.Metadata().HasUserDefinedFunctions() {
// Get all relevant user-defined functions.
blankLine()
if err := c.PrintRelevantCreateUdf(&buf, strings.ToLower(b.stmt), b.flags.RedactValues, &b.errorStrings); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/opt/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,9 @@ func (md *Metadata) AllUserDefinedTypes() []*types.T {
return md.userDefinedTypesSlice
}

// AllUserDefinedFunctions returns all user defined functions used in this query.
func (md *Metadata) AllUserDefinedFunctions() map[cat.StableID]*tree.Overload {
return md.udfDeps
// HasUserDefinedFunctions returns true if the query references a UDF.
func (md *Metadata) HasUserDefinedFunctions() bool {
return len(md.udfDeps) > 0
}

// AddUserDefinedFunction adds a user-defined function to the metadata for this
Expand Down

0 comments on commit a6a2ccc

Please sign in to comment.