xuefuz commented on a change in pull request #8920: [FLINK-13024][table]
integrate FunctionCatalog with CatalogManager
URL: https://github.com/apache/flink/pull/8920#discussion_r301823883
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
##########
@@ -116,14 +125,60 @@ public void registerScalarFunction(String name,
ScalarFunction function) {
}
public String[] getUserDefinedFunctions() {
- return userFunctions.values().stream()
- .map(FunctionDefinition::toString)
- .toArray(String[]::new);
+ List<String> result = new ArrayList<>();
+
+ // Get functions in catalog
+ Catalog catalog =
catalogManager.getCatalog(catalogManager.getCurrentCatalog()).get();
+ try {
+
result.addAll(catalog.listFunctions(catalogManager.getCurrentDatabase()));
+ } catch (DatabaseNotExistException e) {
+ // Ignore since there will always be a current database
of the current catalog
+ }
+
+ // Get functions registered in memory
+ result.addAll(
+ userFunctions.values().stream()
+ .map(FunctionDefinition::toString)
+ .collect(Collectors.toList()));
+
+ // Get built-in functions
+ result.addAll(
+ BuiltInFunctionDefinitions.getDefinitions()
+ .stream()
+ .map(f -> f.getName())
+ .collect(Collectors.toList()));
+
+ return result.stream()
+ .map(n -> normalizeName(n))
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
}
@Override
public Optional<FunctionLookup.Result> lookupFunction(String name) {
Review comment:
I'm curious about the format of name here. In complete form, a lookup is for
a function like catalog.database.functionName, though it's possible to have
database.functionName or just functionName. When it's just functionName, it can
be either refer to one in current catalog/db or a built-in function.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services