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 2022/06/09 06:08:30 UTC

[GitHub] [flink] HuangZhenQiu commented on a diff in pull request #19742: [FLINK-27651][table] Support CREATE FUNCTION USING JAR syntax

HuangZhenQiu commented on code in PR #19742:
URL: https://github.com/apache/flink/pull/19742#discussion_r893103784


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlToOperationConverterTest.java:
##########
@@ -1213,6 +1218,54 @@ public void testCreateTableWithMetadataColumn() {
         assertThat(actualSchema).isEqualTo(expectedSchema);
     }
 
+    @Test
+    public void testCreateFunction() {
+        // test create catalog function
+        String sql =
+                "CREATE FUNCTION test_udf AS 'org.apache.fink.function.function1' "
+                        + "LANGUAGE JAVA USING JAR 'file:///path/to/test.jar'";
+        final FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
+        Operation operation = parse(sql, planner, getParserBySqlDialect(SqlDialect.DEFAULT));
+        assertThat(operation).isInstanceOf(CreateCatalogFunctionOperation.class);
+        CatalogFunction actualFunction =
+                ((CreateCatalogFunctionOperation) operation).getCatalogFunction();
+
+        assertThat(operation.asSummaryString())
+                .isEqualTo(
+                        "CREATE CATALOG FUNCTION: (catalogFunction: [Optional[This is a user-defined function]], "
+                                + "identifier: [`builtin`.`default`.`test_udf`], ignoreIfExists: [false], isTemporary: [false])");
+
+        // here doesn't assert the CatalogFunction directly because of the isGeneric method will
+        // load the class
+        assertThat(actualFunction.getClassName()).isEqualTo("org.apache.fink.function.function1");

Review Comment:
   +1. Can we add the equal function for CatalogFunctionImpl?



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

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org