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_r298405079
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##########
 @@ -116,15 +119,48 @@ 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 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) {
-               final FunctionDefinition userCandidate = 
userFunctions.get(normalizeName(name));
+               String functionName = normalizeName(name);
+
+               Catalog catalog = 
catalogManager.getCatalog(catalogManager.getCurrentCatalog()).get();
+
+               FunctionDefinition userCandidate = null;
+               try {
+                       CatalogFunction catalogFunction = catalog.getFunction(
+                               new 
ObjectPath(catalogManager.getCurrentDatabase(), functionName));
+
+                       // TODO: use FunctionDefintionFactory to initiate a 
FunctionDefinition from CatalogFunction
 
 Review comment:
   we need FunctionDefintionFactory here

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to