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_r353719484
##########
File path:
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/operations/SqlToOperationConverter.java
##########
@@ -179,6 +195,72 @@ private Operation convertDropTable(SqlDropTable
sqlDropTable) {
return new DropTableOperation(identifier,
sqlDropTable.getIfExists());
}
+ /** Convert CREATE FUNCTION statement. */
+ private Operation convertCreateFunction(SqlCreateFunction
sqlCreateFunction) {
+ FunctionLanguage language =
parseLanguage(sqlCreateFunction.getFunctionLanguage());
+ CatalogFunction catalogFunction = new CatalogFunctionImpl(
+ sqlCreateFunction.getFunctionClassName().toValue(),
language);
+
+ UnresolvedIdentifier unresolvedIdentifier =
UnresolvedIdentifier.of(sqlCreateFunction.getFunctionIdentifier());
+ ObjectIdentifier identifier =
catalogManager.qualifyIdentifier(unresolvedIdentifier);
+
+ return new CreateFunctionOperation(
+ identifier,
+ catalogFunction,
+ sqlCreateFunction.isIfNotExists()
+ );
+ }
+
+ /** Convert ALTER FUNCTION statement. */
+ private Operation convertAlterFunction(SqlAlterFunction
sqlAlterFunction) {
+ FunctionLanguage language =
parseLanguage(sqlAlterFunction.getFunctionLanguage());
+ CatalogFunction catalogFunction = new CatalogFunctionImpl(
+ sqlAlterFunction.getFunctionClassName().toValue(),
language);
+
+ UnresolvedIdentifier unresolvedIdentifier =
UnresolvedIdentifier.of(sqlAlterFunction.getFunctionIdentifier());
+ ObjectIdentifier identifier =
catalogManager.qualifyIdentifier(unresolvedIdentifier);
+ return new AlterFunctionOperation(
+ identifier,
+ catalogFunction,
+ sqlAlterFunction.isIfExists()
+ );
+ }
+
+ /** Convert DROP FUNCTION statement. */
+ private Operation convertDropFunction(SqlDropFunction sqlDropFunction) {
+ UnresolvedIdentifier unresolvedIdentifier =
UnresolvedIdentifier.of(sqlDropFunction.getFunctionIdentifier());
+ ObjectIdentifier identifier =
catalogManager.qualifyIdentifier(unresolvedIdentifier);
+
+ return new DropFunctionOperation(
+ identifier,
+ sqlDropFunction.getIfExists());
+ }
+
+ /**
+ * Converts language string the FunctionLanguage.
+ * @param languageString the language string from SQL parser
+ * @return supported FunctionLanguage otherwise raise
UnsupportedOperationException.
Review comment:
`Converts language string` -> `Converts language string to`, also keep an
empty line between the doc and `@param`.
You can use `@throws` to mark the probable exception.
----------------------------------------------------------------
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