bowenli86 commented on a change in pull request #8920: [FLINK-13024][table]
integrate FunctionCatalog with CatalogManager
URL: https://github.com/apache/flink/pull/8920#discussion_r302274809
##########
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:
@twalthr Agree. As I mentioned in the comment, I hope to change this API in
a followup PR rather than this PR. As such a change would require refactoring
upstream code which will complicate this PR itself.
----------------------------------------------------------------
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