You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/12/06 23:15:09 UTC

[GitHub] [flink] HuangZhenQiu commented on a change in pull request #10476: [FLINK-14911] [table] register and drop temp catalog functions from D…

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


With regards,
Apache Git Services