danny0405 commented on a change in pull request #10388: [FLINK-14912][Table] 
create, drop catalog functions through catalog manager
URL: https://github.com/apache/flink/pull/10388#discussion_r353725114
 
 

 ##########
 File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/internal/TableEnvImpl.scala
 ##########
 @@ -669,24 +673,67 @@ abstract class TableEnvImpl(
       .map(_.getTable)
   }
 
+  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)
+    } catch {
+      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)
+    } catch {
+      case ex: FunctionNotExistException => throw new 
ValidationException(exMsg, ex)
+      case ex: Exception => throw new TableException(exMsg, ex)
+    }
+  }
+
+  private def dropCatalogFunction(dropFunctionOperation: 
DropFunctionOperation) = {
+    val catalog = 
getCatalogOrThrowException(dropFunctionOperation.getFunctionIdentifier.getCatalogName)
+    val exMsg = getDDLOpExecuteErrorMsg(dropFunctionOperation.asSummaryString)
+
+    try {
+      catalog.dropFunction(
+        dropFunctionOperation.getFunctionIdentifier.toObjectPath,
+        dropFunctionOperation.isIfExists)
+    } catch {
+      case ex: FunctionNotExistException => throw new 
ValidationException(exMsg, ex)
+      case ex: Exception => throw new TableException(exMsg, ex)
+    }
+  }
+
   /** Returns the [[FlinkRelBuilder]] of this TableEnvironment. */
-  private[flink] def getRelBuilder: FlinkRelBuilder = {
+  private[flink] def getRelBuilder = {
     val currentCatalogName = catalogManager.getCurrentCatalog
     val currentDatabase = catalogManager.getCurrentDatabase
 
     planningConfigurationBuilder.createRelBuilder(currentCatalogName, 
currentDatabase)
   }
 
-  private[flink] def getFunctionCatalog: FunctionCatalog = {
+  private[flink] def getFunctionCatalog = {
     functionCatalog
   }
 
-  private[flink] def getParserConfig: SqlParser.Config = 
planningConfigurationBuilder
+  private[flink] def getParserConfig = planningConfigurationBuilder
     .getSqlParserConfig
 
   /** Returns the Calcite [[FrameworkConfig]] of this TableEnvironment. */
   @VisibleForTesting
-  private[flink] def getFlinkPlanner: FlinkPlannerImpl = {
 
 Review comment:
   Unnecessary change ?

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