This is an automated email from the ASF dual-hosted git repository.

guoweijie pushed a commit to branch release-1.17
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.17 by this push:
     new d40d4dd26ac [FLINK-31398][sql-gateway] OperationExecutor is no longer 
set context classloader when executing statement.
d40d4dd26ac is described below

commit d40d4dd26ac544307583477b6930e7af50330935
Author: Weijie Guo <[email protected]>
AuthorDate: Wed Mar 29 16:01:49 2023 +0800

    [FLINK-31398][sql-gateway] OperationExecutor is no longer set context 
classloader when executing statement.
---
 .../service/operation/OperationExecutor.java       | 27 ++++++++--------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git 
a/flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java
 
b/flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java
index f705536442e..0017db2fdf7 100644
--- 
a/flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java
+++ 
b/flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java
@@ -90,7 +90,6 @@ import org.apache.flink.util.CollectionUtil;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.Preconditions;
-import org.apache.flink.util.TemporaryClassLoaderContext;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -182,23 +181,17 @@ public class OperationExecutor {
 
     public ResultFetcher executeStatement(OperationHandle handle, String 
statement) {
         // Instantiate the TableEnvironment lazily
-        // TODO: remove the usage of the context classloader until {@link
-        // HiveParserUtils}#getFunctionInfo use ResourceManager explicitly.
-        try (TemporaryClassLoaderContext ignored =
-                TemporaryClassLoaderContext.of(
-                        
sessionContext.getSessionState().resourceManager.getUserClassLoader())) {
-            TableEnvironmentInternal tableEnv = getTableEnvironment();
-            List<Operation> parsedOperations = 
tableEnv.getParser().parse(statement);
-            if (parsedOperations.size() > 1) {
-                throw new UnsupportedOperationException(
-                        "Unsupported SQL statement! Execute statement only 
accepts a single SQL statement or "
-                                + "multiple 'INSERT INTO' statements wrapped 
in a 'STATEMENT SET' block.");
-            }
-            Operation op = parsedOperations.get(0);
-            return sessionContext.isStatementSetState()
-                    ? executeOperationInStatementSetState(tableEnv, handle, op)
-                    : executeOperation(tableEnv, handle, op);
+        TableEnvironmentInternal tableEnv = getTableEnvironment();
+        List<Operation> parsedOperations = 
tableEnv.getParser().parse(statement);
+        if (parsedOperations.size() > 1) {
+            throw new UnsupportedOperationException(
+                    "Unsupported SQL statement! Execute statement only accepts 
a single SQL statement or "
+                            + "multiple 'INSERT INTO' statements wrapped in a 
'STATEMENT SET' block.");
         }
+        Operation op = parsedOperations.get(0);
+        return sessionContext.isStatementSetState()
+                ? executeOperationInStatementSetState(tableEnv, handle, op)
+                : executeOperation(tableEnv, handle, op);
     }
 
     public String getCurrentCatalog() {

Reply via email to