Skip to content

Commit

Permalink
[FLINK-31398][sql-gateway] OperationExecutor is no longer set context…
Browse files Browse the repository at this point in the history
… classloader when executing statement.
  • Loading branch information
reswqa committed Mar 29, 2023
1 parent 0dd9bcb commit 171b25b
Showing 1 changed file with 10 additions and 17 deletions.
Expand Up @@ -90,7 +90,6 @@
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;
Expand Down Expand Up @@ -182,23 +181,17 @@ public ResultFetcher configureSession(OperationHandle handle, String statement)

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() {
Expand Down

0 comments on commit 171b25b

Please sign in to comment.