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_r355130113
##########
File path:
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/internal/TableEnvImpl.scala
##########
@@ -696,51 +696,116 @@ abstract class TableEnvImpl(
}
private def createCatalogFunction(createFunctionOperation:
CreateFunctionOperation)= {
- val catalog = getCatalogOrThrowException(
- createFunctionOperation.getFunctionIdentifier.getCatalogName)
val exMsg =
getDDLOpExecuteErrorMsg(createFunctionOperation.asSummaryString)
try {
- catalog.createFunction(
- createFunctionOperation.getFunctionIdentifier.toObjectPath,
- createFunctionOperation.getCatalogFunction,
- createFunctionOperation.isIgnoreIfExists)
+ val function = createFunctionOperation.getCatalogFunction
+ if (function.isTemporary) {
+ val exist = functionCatalog.hasTemporaryCatalogFunction(
+ createFunctionOperation.getFunctionIdentifier);
+ if (!exist) {
+ val functionDefinition =
FunctionDefinitionUtil.createFunctionDefinition(
+ createFunctionOperation.getFunctionName, function)
+ registerFunctionInFunctionCatalog(
+ createFunctionOperation.getFunctionIdentifier,
+ functionDefinition)
+ } else if (!createFunctionOperation.isIgnoreIfExists) {
+ throw new
FunctionAlreadyExistException(FunctionCatalog.TEMPORARY_CATALOG,
+ createFunctionOperation.getFunctionIdentifier.toObjectPath)
+ }
+ } else {
+ val catalog = getCatalogOrThrowException(
+ createFunctionOperation.getFunctionIdentifier.getCatalogName)
+ catalog.createFunction(
+ createFunctionOperation.getFunctionIdentifier.toObjectPath,
+ createFunctionOperation.getCatalogFunction,
+ createFunctionOperation.isIgnoreIfExists)
+ }
} catch {
+ case ex: ValidationException => throw ex
case ex: FunctionAlreadyExistException => throw new
ValidationException(exMsg, ex)
case ex: Exception => throw new TableException(exMsg, ex)
}
}
private def alterCatalogFunction(alterFunctionOperation:
AlterFunctionOperation) = {
- val catalog = getCatalogOrThrowException(
- alterFunctionOperation.getFunctionIdentifier.getCatalogName)
val exMsg = getDDLOpExecuteErrorMsg(alterFunctionOperation.asSummaryString)
-
try {
- catalog.alterFunction(
- alterFunctionOperation.getFunctionIdentifier.toObjectPath,
- alterFunctionOperation.getCatalogFunction,
- alterFunctionOperation.isIfExists)
+ val function = alterFunctionOperation.getCatalogFunction
+ if (function.isTemporary) {
+ throw new ValidationException("Alter temporary function is not
supported")
+ } else {
+ val catalog = getCatalogOrThrowException(
+ alterFunctionOperation.getFunctionIdentifier.getCatalogName)
+ catalog.alterFunction(
+ alterFunctionOperation.getFunctionIdentifier.toObjectPath,
+ alterFunctionOperation.getCatalogFunction,
+ alterFunctionOperation.isIfExists)
+ }
} catch {
+ case ex: ValidationException => throw ex
Review comment:
Done
----------------------------------------------------------------
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