danny0405 commented on a change in pull request #1455: [CALCITE-3349] Add 
create and drop function into SqlKind ddl enumerations
URL: https://github.com/apache/calcite/pull/1455#discussion_r326998422
 
 

 ##########
 File path: server/src/test/java/org/apache/calcite/test/ServerTest.java
 ##########
 @@ -166,6 +166,42 @@ static Connection connect() throws SQLException {
     }
   }
 
+  @Test public void testCreateFunction() throws Exception {
+    try (Connection c = connect();
+         Statement s = c.createStatement()) {
+      boolean b = s.execute("create schema s");
+      assertThat(b, is(false));
+      try {
+        boolean f = s.execute("create function if not exists s.t \n" +
+                "as 'org.apache.calcite.udf.TableFun.demoUdf'\n" +
+                "using jar 'file:/path/udf/udf-0.0.1-SNAPSHOT.jar'");
+      } catch (SQLException e) {
+        assertThat(e.getMessage(),
+                containsString("Sql create function ddl is not support yet"));
+      }
+    }
+  }
+
+  @Test public void testDropFunction() throws Exception {
+    try (Connection c = connect();
+         Statement s = c.createStatement()) {
+      boolean b = s.execute("create schema s");
+      assertThat(b, is(false));
+
+      boolean f = s.execute("drop function if exists t");
+      assertThat(f, is(false));
+
+      try {
+        boolean f2 = s.execute("drop function t");
+        assertThat(f2, is(false));
+      } catch (SQLException e) {
+        assertThat(e.getMessage(),
+                containsString("Error while executing SQL \"drop function 
t\":" +
+                        " At line 1, column 15: Type 'T' not found"));
 
 Review comment:
   Oops, my mistake, you actually implement the "Drop function". Then we should 
add more tests about drop function:
   
   **Positive tests**
   1. Add a function in the schema and test remove with(without) if exists
   2. Test drop function with specified catalog name and database name, i.e. 
`DROP FUNCTION catalog_name.db_name.func_name`
   
   **Negative tests**
   1. Test drop function what does not exist
   2. Test drop function with case_sensive true but not found

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