luoyuxia commented on code in PR #22903:
URL: https://github.com/apache/flink/pull/22903#discussion_r1250086347


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/OperationLikeType.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.operations.utils;
+
+/** Like types utils. */

Review Comment:
   I won't consider the enum `OperationLikeType` as  util. For me, it's just an 
enum type.



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java:
##########
@@ -338,6 +338,22 @@ public String[] getFunctions() {
         return result.toArray(new String[0]);
     }
 
+    /**
+     * Get names of all functions, including temp system functions, system 
functions, temp catalog
+     * functions and catalog functions with specific catalog and database.
+     */
+    public String[] getFunctions(String catalogName, String databaseName) {

Review Comment:
   I think We can share some logic with method `getFunctions()`



##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -759,13 +759,23 @@ SHOW CREATE VIEW [catalog_name.][db_name.]view_name
 ## SHOW FUNCTIONS
 
 ```sql
-SHOW [USER] FUNCTIONS
+SHOW [USER] FUNCTIONS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] 
(LIKE | ILIKE) <sql_like_pattern> ]
 ```
 
-展示当前 catalog 和当前 database 中所有的 function,包括:系统 function 和用户定义的 function。
+展示当前 catalog 和当前 database 中所有的 function,包括:系统 function 和用户定义的 function, 
另外返回的结果能被一个可选的匹配字符串过滤。
 
 **USER**
-仅仅展示当前 catalog 和当前 database 中用户定义的 function。
+展示当前 catalog 和当前 database 中仅用户定义的 function, 另外返回的结果能被一个可选的匹配字符串过滤。
+
+**LIKE**
+根据可选的 `LIKE` 语句与 `<sql_like_pattern>` 是否模糊相似的所有 function。

Review Comment:
   模糊相似 -> 模糊匹配
   ?



##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -759,13 +759,23 @@ SHOW CREATE VIEW [catalog_name.][db_name.]view_name
 ## SHOW FUNCTIONS
 
 ```sql
-SHOW [USER] FUNCTIONS
+SHOW [USER] FUNCTIONS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] 
(LIKE | ILIKE) <sql_like_pattern> ]
 ```
 
-展示当前 catalog 和当前 database 中所有的 function,包括:系统 function 和用户定义的 function。
+展示当前 catalog 和当前 database 中所有的 function,包括:系统 function 和用户定义的 function, 
另外返回的结果能被一个可选的匹配字符串过滤。
 
 **USER**
-仅仅展示当前 catalog 和当前 database 中用户定义的 function。
+展示当前 catalog 和当前 database 中仅用户定义的 function, 另外返回的结果能被一个可选的匹配字符串过滤。
+
+**LIKE**
+根据可选的 `LIKE` 语句与 `<sql_like_pattern>` 是否模糊相似的所有 function。

Review Comment:
   模糊相似 -> 模糊匹配
   ?



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/OperationLikeType.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.operations.utils;
+
+/** Like types utils. */
+public enum OperationLikeType {
+    /** sql like pattern, case sensitive. */

Review Comment:
   ```suggestion
       /** sql like pattern, case sensitive to match a pattern. */
   ```
   ?



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/OperationLikeType.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.operations.utils;
+
+/** Like types utils. */
+public enum OperationLikeType {
+    /** sql like pattern, case sensitive. */
+    LIKE,
+    /** sql like pattern, case insensitive. */

Review Comment:
   ```suggestion
       /** sql like pattern, case insensitive to match a pattern. */
   ```
   ?



##########
flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -437,21 +437,54 @@ SqlAlterFunction SqlAlterFunction() :
 
 /**
 * Parses a show functions statement.
-* SHOW [USER] FUNCTIONS;
+* SHOW [USER] FUNCTIONS [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] 
(LIKE | ILIKE) pattern;
 */
 SqlShowFunctions SqlShowFunctions() :
 {
     SqlParserPos pos;
     boolean requireUser = false;
+    String prep = null;
+    SqlIdentifier databaseName = null;
+    String likeType = null;
+    SqlCharStringLiteral likeLiteral = null;
+    boolean notLike = false;
 }
 {
     <SHOW> { pos = getPos();}
     [
         <USER> { requireUser = true; }
     ]
     <FUNCTIONS>
+    [
+        ( <FROM> { prep = "FROM"; } | <IN> { prep = "IN"; } )
+        { pos = getPos(); }
+        databaseName = CompoundIdentifier()
+    ]
+    [
+        [
+            <NOT>
+            {
+                notLike = true;
+            }
+        ]
+        (
+            <LIKE>  <QUOTED_STRING>
+            {
+                likeType = "LIKE";
+                String likeCondition1 = SqlParserUtil.parseString(token.image);

Review Comment:
   extract 
   ```
   String likeCondition1 = SqlParserUtil.parseString(token.image);
   likeLiteral = SqlLiteral.createCharString(likeCondition1, getPos());
   ```
   to external so that both Like and ILike can share the logic ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to