You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "sohardforaname (via GitHub)" <gi...@apache.org> on 2023/06/29 13:23:56 UTC

[GitHub] [doris] sohardforaname commented on a diff in pull request #18257: [Feature](Nereids)support udf for Nereids

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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org