yuzelin commented on code in PR #20479:
URL: https://github.com/apache/flink/pull/20479#discussion_r939831055


##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/endpoint/hive/util/OperationExecutorFactory.java:
##########
@@ -203,6 +230,78 @@ private static ResultSet executeGetTables(
                         .collect(Collectors.toList()));
     }
 
+    private static ResultSet executeGetFunctions(
+            SqlGatewayService service,
+            SessionHandle sessionHandle,
+            @Nullable String catalogName,
+            @Nullable String databasePattern,
+            @Nullable String functionNamePattern) {
+        String specifiedCatalogName =
+                isNullOrEmpty(catalogName) ? 
service.getCurrentCatalog(sessionHandle) : catalogName;
+
+        Set<FunctionInfo> candidates = new HashSet<>();
+        // Add user defined functions
+        for (String databaseName :
+                filter(
+                        service.listDatabases(sessionHandle, 
specifiedCatalogName),
+                        databasePattern)) {
+            candidates.addAll(
+                    service.listUserDefinedFunctions(
+                            sessionHandle, specifiedCatalogName, 
databaseName));
+        }
+        // Add system functions
+        if (isNullOrEmpty(catalogName) && isNullOrEmpty(databasePattern)) {
+            candidates.addAll(service.listSystemFunctions(sessionHandle));
+        }
+        // Filter out unmatched functions
+        Set<FunctionInfo> matchedFunctions =
+                filter(
+                        candidates,
+                        candidate -> 
candidate.getIdentifier().getFunctionName(),
+                        functionNamePattern);
+        return new ResultSet(
+                EOS,
+                null,
+                GET_FUNCTIONS_SCHEMA,

Review Comment:
   Maybe you can add buildResultSet method similar to 
HiveServer2Schemas#buildSchema since the result set always contains 'EOS' and 
'null'.



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