wuchong commented on a change in pull request #15110:
URL: https://github.com/apache/flink/pull/15110#discussion_r591006274



##########
File path: docs/content.zh/docs/dev/table/sql/show.md
##########
@@ -244,6 +266,17 @@ table_env.execute_sql("SHOW FUNCTIONS").print()
 # |           ... |
 # +---------------+
 
+# create a user defined function
+table_env.execute_sql("CREATE FUNCTION f1 AS ...");
+# show user defined functions
+table_env.execute_sql("SHOW USER FUNCTIONS").print();

Review comment:
       We don't need ending `;` for python. 

##########
File path: docs/content/docs/dev/table/sql/show.md
##########
@@ -329,7 +369,7 @@ Show all views in the current catalog and the current 
database.
 ## SHOW FUNCTIONS
 
 ```sql
-SHOW FUNCTIONS
+SHOW [USER] FUNCTIONS
 ```
 
-Show all functions including temp system functions, system functions, temp 
catalog functions and catalog functions in the current catalog and current 
database.
+Show all or user defined functions including temp system functions, system 
functions, temp catalog functions and catalog functions in the current catalog 
and current database.

Review comment:
       ```suggestion
   Show all functions including system functions and user-defined functions in 
the current catalog and current database.
   
   **USER**
   Show only user-defined functions in the current catalog and current database.
   ```

##########
File path: 
flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/LocalExecutorITCase.java
##########
@@ -350,6 +350,19 @@ public void testListUserDefinedFunctions() throws 
Exception {
         executor.closeSession(sessionId);
     }
 
+    @Test
+    public void testListUserDefinedFunctions() throws Exception {
+        final Executor executor = createDefaultExecutor(clusterClient);
+        final SessionContext session = new SessionContext("test-session", new 
Environment());
+        String sessionId = executor.openSession(session);
+        assertEquals("test-session", sessionId);
+
+        assertShowResult(
+                executor.executeSql(sessionId, "SHOW USER FUNCTIONS"),
+                hasItems("aggregateudf", "tableudf", "scalarudf"));

Review comment:
       assert the full list, there shouldn't other elements. 
   
   ```java
   assertShowResult(
                   executor.executeSql(sessionId, "SHOW USER FUNCTIONS"),
                   Arrays.asList("aggregateudf", "tableudf", "scalarudf"));
   ```

##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowFunctionsOperation.java
##########
@@ -18,11 +18,21 @@
 
 package org.apache.flink.table.operations;
 
-/** Operation to describe a SHOW FUNCTIONS statement. */
+/** Operation to describe a SHOW [USER] FUNCTIONS statement. */
 public class ShowFunctionsOperation implements ShowOperation {
 
+    private final boolean requireUser;

Review comment:
       `ShowFunctionsOperation` is a public API, I sugget to make the 
interaface more extensible. What about having a enum type instead of boolean 
here?
   
   
   ```java
   public enum FunctionScope {
       ALL,
       USER
       // we may introduce SYSTEM in the future
   }
   ```

##########
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java
##########
@@ -89,7 +89,7 @@ private CliStrings() {
                     .append(
                             formatCommand(
                                     SqlCommand.SHOW_FUNCTIONS,
-                                    "Shows all user-defined and built-in 
functions."))
+                                    "Shows all user-defined and built-in 
functions or all user-defined functions."))

Review comment:
       ```suggestion
                                       "Shows all user-defined and built-in 
functions or only user-defined functions. Syntax: 'SHOW [USER] FUNCTIONS;'"))
   ```

##########
File path: 
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/operations/SqlToOperationConverterTest.java
##########
@@ -372,6 +373,15 @@ public void testShowFullModules() {
         assertEquals("SHOW FULL MODULES", 
showModulesOperation.asSummaryString());
     }
 
+    @Test
+    public void testShowFunctions() {
+        final String sql1 = "SHOW FUNCTIONS";
+        runShowFunctions(sql1, sql1, false);

Review comment:
       rename to `assertShowFunctions` or `verifyShowFunctions`.

##########
File path: 
flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/LocalExecutorITCase.java
##########
@@ -350,6 +350,19 @@ public void testListUserDefinedFunctions() throws 
Exception {
         executor.closeSession(sessionId);

Review comment:
       We should assert the size too, otherwise, it will pass if it returns 
user-defined functions only.
   
   ```java
   assertShowResult(
                   executor.executeSql(sessionId, "SHOW FUNCTIONS"),
                   allOf(
                           iterableWithSize(greaterThan(3)),
                           hasItems("aggregateudf", "tableudf", "scalarudf")));
   ```

##########
File path: 
flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/LocalExecutorITCase.java
##########
@@ -350,6 +350,19 @@ public void testListUserDefinedFunctions() throws 
Exception {
         executor.closeSession(sessionId);
     }
 
+    @Test
+    public void testListUserDefinedFunctions() throws Exception {
+        final Executor executor = createDefaultExecutor(clusterClient);
+        final SessionContext session = new SessionContext("test-session", new 
Environment());
+        String sessionId = executor.openSession(session);
+        assertEquals("test-session", sessionId);
+
+        assertShowResult(
+                executor.executeSql(sessionId, "SHOW USER FUNCTIONS"),
+                hasItems("aggregateudf", "tableudf", "scalarudf"));

Review comment:
       assert the full list, there shouldn't contain other elements. 
   
   ```java
   assertShowResult(
                   executor.executeSql(sessionId, "SHOW USER FUNCTIONS"),
                   Arrays.asList("aggregateudf", "tableudf", "scalarudf"));
   ```




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to