HuangZhenQiu commented on a change in pull request #10476: [FLINK-14911] 
[table] register and drop temp catalog functions from D…
URL: https://github.com/apache/flink/pull/10476#discussion_r355068472
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
 ##########
 @@ -729,13 +738,33 @@ private void registerTableSinkInternal(String name, 
TableSink<?> tableSink) {
        }
 
        private void createCatalogFunction(CreateFunctionOperation 
createFunctionOperation) {
-               Catalog catalog = 
getCatalogOrThrowException(createFunctionOperation.getFunctionIdentifier().getCatalogName());
                String exMsg = 
getDDLOpExecuteErrorMsg(createFunctionOperation.asSummaryString());
                try {
-                       catalog.createFunction(
-                               
createFunctionOperation.getFunctionIdentifier().toObjectPath(),
-                               createFunctionOperation.getCatalogFunction(),
-                               createFunctionOperation.isIgnoreIfExists());
+                       CatalogFunction function = 
createFunctionOperation.getCatalogFunction();
+                       if (function.isTemporary()) {
+                               boolean exist = 
functionCatalog.hasTemporaryCatalogFunction(
+                                       
createFunctionOperation.getFunctionIdentifier());
+                               if (!exist) {
+                                       FunctionDefinition functionDefinition = 
FunctionDefinitionUtil.createFunctionDefinition(
+                                               
createFunctionOperation.getFunctionName(),
+                                               function);
+                                       registerFunctionInFunctionCatalog(
+                                               
createFunctionOperation.getFunctionIdentifier(),
+                                               functionDefinition);
+                               } else if 
(!createFunctionOperation.isIgnoreIfExists()) {
+                                       throw new 
FunctionAlreadyExistException(FunctionCatalog.TEMPORARY_CATALOG,
+                                               
createFunctionOperation.getFunctionIdentifier().toObjectPath());
+                               }
+                       } else {
+                               Catalog catalog = getCatalogOrThrowException(
+                                       
createFunctionOperation.getFunctionIdentifier().getCatalogName());
+                               catalog.createFunction(
 
 Review comment:
   It is the current behavior, right? The function can throw both catalog 
doesn't exist Validation Exception and also FunctionAlreadyExistException. They 
are handled in this way, so that validation exception can be thrown without 
wrapped to a TableException.

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