twalthr commented on a change in pull request #10942: [FLINK-15487][table] 
Allow registering FLIP-65 functions in TableEnvironment
URL: https://github.com/apache/flink/pull/10942#discussion_r372306128
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##########
 @@ -81,8 +85,283 @@ public void 
setPlannerTypeInferenceUtil(PlannerTypeInferenceUtil plannerTypeInfe
                this.plannerTypeInferenceUtil = plannerTypeInferenceUtil;
        }
 
+       /**
+        * Registers a temporary system function.
+        */
+       public void registerTemporarySystemFunction(
+                       String name,
+                       FunctionDefinition definition,
+                       boolean ignoreIfExists) {
+               final String normalizedName = 
FunctionIdentifier.normalizeName(name);
+
+               if (definition instanceof UserDefinedFunction) {
+                       try {
+                               
UserDefinedFunctionHelper.prepareInstance(config, (UserDefinedFunction) 
definition);
+                       } catch (Throwable t) {
+                               throw new ValidationException(
+                                       String.format(
+                                               "Could not register temporary 
system function '%s' due to implementation errors.",
+                                               name),
+                                       t);
+                       }
+               }
+
+               if (!tempSystemFunctions.containsKey(normalizedName)) {
+                       tempSystemFunctions.put(normalizedName, definition);
+               } else if (!ignoreIfExists) {
+                       throw new ValidationException(
+                               String.format(
+                                       "Could not register temporary system 
function. A function named '%s' does already exist.",
+                                       name));
+               }
+       }
+
+       /**
+        * Drops a temporary system function. Returns true if a function was 
dropped.
+        */
+       public boolean dropTemporarySystemFunction(
+                       String name,
+                       boolean ignoreIfNotExist) {
+               final String normalizedName = 
FunctionIdentifier.normalizeName(name);
+               final FunctionDefinition definition = 
tempSystemFunctions.remove(normalizedName);
+
+               if (definition == null && !ignoreIfNotExist) {
+                       throw new ValidationException(
+                               String.format(
+                                       "Could not drop temporary system 
function. A function named '%s' doesn't exist.",
+                                       name));
+               }
+
+               return definition != null;
+       }
+
+       /**
+        * Registers a temporary catalog function.
+        */
+       public void registerTemporaryCatalogFunction(
+                       UnresolvedIdentifier unresolvedIdentifier,
 
 Review comment:
   I also observed these inconsistencies. I think the catalog manager can 
resolve identifiers internally and thus can just expose `UnresolvedIdentifier`. 
That's why all my newly added methods take the unresolved one.
   
   We said that operation should be fully resolved but that was before the DDL. 
So things might have changed a bit. Maybe we should distinguish between 
resolved and unresolved operations. Let's discuss this in a follow up issue.

----------------------------------------------------------------
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

Reply via email to