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

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
 ##########
 @@ -744,34 +773,91 @@ private void 
createCatalogFunction(CreateFunctionOperation createFunctionOperati
        }
 
        private void alterCatalogFunction(AlterFunctionOperation 
alterFunctionOperation) {
-               Catalog catalog = 
getCatalogOrThrowException(alterFunctionOperation.getFunctionIdentifier().getCatalogName());
                String exMsg = 
getDDLOpExecuteErrorMsg(alterFunctionOperation.asSummaryString());
                try {
-                       catalog.alterFunction(
-                               
alterFunctionOperation.getFunctionIdentifier().toObjectPath(),
-                               alterFunctionOperation.getCatalogFunction(),
-                               alterFunctionOperation.isIfExists());
-               } catch (FunctionNotExistException e) {
+                       CatalogFunction function = 
alterFunctionOperation.getCatalogFunction();
+                       if (function.isTemporary()) {
+                               throw new ValidationException("Alter temporary 
function is not supported");
+                       } else {
+                               Catalog catalog = getCatalogOrThrowException(
+                                       
alterFunctionOperation.getFunctionIdentifier().getCatalogName());
+                               catalog.alterFunction(
+                                       
alterFunctionOperation.getFunctionIdentifier().toObjectPath(),
+                                       function,
+                                       alterFunctionOperation.isIfExists());
+                       }
+               } catch (ValidationException e) {
+                       throw e;
+               }  catch (FunctionNotExistException e) {
                        throw new ValidationException(exMsg, e);
                } catch (Exception e) {
                        throw new TableException(exMsg, e);
                }
        }
 
        private void dropCatalogFunction(DropFunctionOperation 
dropFunctionOperation) {
-               Catalog catalog = 
getCatalogOrThrowException(dropFunctionOperation.getFunctionIdentifier().getCatalogName());
+
                String exMsg = 
getDDLOpExecuteErrorMsg(dropFunctionOperation.asSummaryString());
                try {
-                       catalog.dropFunction(
-                               
dropFunctionOperation.getFunctionIdentifier().toObjectPath(),
-                               dropFunctionOperation.isIfExists());
-               } catch (FunctionNotExistException e) {
+                       if (dropFunctionOperation.isTemporary()) {
+                               boolean exist = 
functionCatalog.hasTemporaryCatalogFunction(
+                                       
dropFunctionOperation.getFunctionIdentifier());
+                               if (exist) {
+                                       functionCatalog.dropTempCatalogFunction(
+                                               
dropFunctionOperation.getFunctionIdentifier(),
+                                               
dropFunctionOperation.isIfExists());
+                               } else if (!dropFunctionOperation.isIfExists()) 
{
+                                       throw new 
FunctionNotExistException(FunctionCatalog.TEMPORARY_CATALOG,
+                                               
dropFunctionOperation.getFunctionIdentifier().toObjectPath());
+                               }
+                       } else {
+                               Catalog catalog = getCatalogOrThrowException
+                                       
(dropFunctionOperation.getFunctionIdentifier().getCatalogName());
+
+                               catalog.dropFunction(
+                                       
dropFunctionOperation.getFunctionIdentifier().toObjectPath(),
+                                       dropFunctionOperation.isIfExists());
+                       }
+               } catch (ValidationException e) {
 
 Review comment:
   ditto

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