Github user eminency commented on a diff in the pull request:
https://github.com/apache/tajo/pull/883#discussion_r47590084
--- Diff:
tajo-core/src/main/java/org/apache/tajo/engine/function/FunctionLoader.java ---
@@ -299,4 +284,38 @@ private static StaticMethodInvocationDesc
extractStaticMethodInvocation(Method m
return sqlFuncs;
}
+
+ public static Collection<FunctionDesc> loadFunctions(TajoConf conf)
throws IOException, AmbiguousFunctionException {
+ List<FunctionDesc> functionList = new
ArrayList<>(loadBuiltinFunctions().values());
+ List<FunctionDesc> udfs = loadUserDefinedFunctions(conf);
+
+ return mergeFunctionLists(functionList, udfs);
+ }
+
+ @SafeVarargs
+ static Collection<FunctionDesc> mergeFunctionLists(List<FunctionDesc>
... functionLists)
+ throws AmbiguousFunctionException {
+
+ Map<Integer, FunctionDesc> funcMap = new HashMap<>();
+ List<FunctionDesc> baseFuncList = functionLists[0];
+
+ // Build a map with a first list
+ for (FunctionDesc desc: baseFuncList) {
+ funcMap.put(desc.hashCodeWithoutType(), desc);
+ }
+
+ // Check duplicates for other function lists(should be UDFs
practically)
+ for (int i=1; i<functionLists.length; i++) {
--- End diff --
I considered about that.
But, there are two reasons why I didn't decide to do it.
First is built-in functions exist statically, that is, they are not changed
frequently. So I thought it could be useless burden to check each startup
(number of built-in functions are more than 200, so number of checking will be
more than 20K times).
Secondly, the check routine is not considering function type as you already
know. But there are already duplicate functions in built-in functions except
function type. For example, there is sum() with or without 'distinct' feature.
Since the check logic should be different, it should be done separately
before current code part.
Thus, I thought the task was not the part of this issue if it should be
done.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---