weiqingy commented on code in PR #26781:
URL: https://github.com/apache/flink/pull/26781#discussion_r2203883233


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java:
##########
@@ -180,28 +182,28 @@ public ResultFetcher configureSession(OperationHandle 
handle, String statement)
         }
         Operation op = parsedOperations.get(0);
 
-        if (!(op instanceof SetOperation)
-                && !(op instanceof ResetOperation)
-                && !(op instanceof CreateOperation)
-                && !(op instanceof DropOperation)
-                && !(op instanceof UseOperation)
-                && !(op instanceof AlterOperation)
-                && !(op instanceof LoadModuleOperation)
-                && !(op instanceof UnloadModuleOperation)
-                && !(op instanceof AddJarOperation)) {
+        // Use LinkedHashMap to preserve insertion order
+        Map<Class<?>, String> ops = new LinkedHashMap<>();
+        ops.put(SetOperation.class, "SET");
+        ops.put(ResetOperation.class, "RESET");
+        ops.put(
+                CreateOperation.class,
+                "CREATE TABLE, CREATE DATABASE, CREATE FUNCTION, CREATE 
CATALOG, CREATE VIEW");
+        ops.put(
+                DropOperation.class,
+                "DROP TABLE, DROP DATABASE, DROP FUNCTION, DROP CATALOG, DROP 
VIEW");
+        ops.put(AlterOperation.class, "ALTER TABLE, ALTER DATABASE, ALTER 
FUNCTION");
+        ops.put(UseOperation.class, "USE CATALOG, USE [CATALOG.]DATABASE, USE 
MODULE");
+        ops.put(LoadModuleOperation.class, "LOAD MODULE");
+        ops.put(UnloadModuleOperation.class, "UNLOAD MODULE");
+        ops.put(AddJarOperation.class, "ADD JAR");
+
+        if (ops.keySet().stream().noneMatch(c -> c.isInstance(op))) {
             throw new UnsupportedOperationException(
                     String.format(
-                            "Unsupported statement for configuring 
session:%s\n"
-                                    + "The configureSession API only supports 
to execute statement of type "
-                                    + "CREATE TABLE, DROP TABLE, ALTER TABLE, "
-                                    + "CREATE DATABASE, DROP DATABASE, ALTER 
DATABASE, "
-                                    + "CREATE FUNCTION, DROP FUNCTION, ALTER 
FUNCTION, "
-                                    + "CREATE CATALOG, DROP CATALOG, "
-                                    + "USE CATALOG, USE [CATALOG.]DATABASE, "
-                                    + "CREATE VIEW, DROP VIEW, "
-                                    + "LOAD MODULE, UNLOAD MODULE, USE MODULE, 
"
-                                    + "ADD JAR.",
-                            statement));
+                            "Unsupported statement for configuring session: 
%s\n"

Review Comment:
   Good catch! Was this PR generated with the AI assistant? 



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