sohardforaname commented on code in PR #18257:
URL: https://github.com/apache/doris/pull/18257#discussion_r1246616022


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java:
##########
@@ -110,4 +126,50 @@ public String getCandidateHint(String name, 
List<FunctionBuilder> candidateBuild
                 .map(builder -> name + builder.toString())
                 .collect(Collectors.joining(", ", "[", "]"));
     }
+
+
+    public void addUdf(String dbName, String name, UdfBuilder builder) {
+        if (dbName == null) {
+            dbName = GLOBAL_FUNCTION;
+        }
+        synchronized (name2UdfBuilders) {
+            Map<String, List<FunctionBuilder>> builders = name2UdfBuilders
+                    .computeIfAbsent(dbName, k -> Maps.newHashMap());
+            builders.computeIfAbsent(name, k -> 
Lists.newArrayList()).add(builder);
+        }
+    }
+
+    public void dropUdf(String dbName, String name, List<DataType> argTypes) {
+        if (dbName == null) {
+            dbName = GLOBAL_FUNCTION;
+        }
+        synchronized (name2UdfBuilders) {
+            Map<String, List<FunctionBuilder>> builders = 
name2UdfBuilders.getOrDefault(dbName, ImmutableMap.of());
+            builders.getOrDefault(name, Lists.newArrayList()).removeIf(builder 
-> ((UdfBuilder) builder).getArgTypes()
+                    .equals(argTypes));
+        }
+    }
+
+    /**
+     * for test
+     */
+    public List<FunctionBuilder> findUdfBuilder(String dbName, String name) {
+        List<String> scopes = ImmutableList.of(GLOBAL_FUNCTION);
+        if (ConnectContext.get() != null) {
+            dbName = 
ClusterNamespace.getFullName(ConnectContext.get().getClusterName(),
+                    dbName == null ? ConnectContext.get().getDatabase() : 
dbName);

Review Comment:
   it's sure we do getFullName in addUdf and dropUdf



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to