KurtYoung commented on a change in pull request #10454:
[FLINK-13195][sql-client] Add create(drop) table support for SqlClient
URL: https://github.com/apache/flink/pull/10454#discussion_r355094279
##########
File path:
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
##########
@@ -198,37 +198,24 @@ public void start() {
// nothing to do yet
}
- /**
- * Create a new {@link ExecutionContext} by merging the default
environment the the environment in session context.
- */
- private ExecutionContext<?> createExecutionContext(SessionContext
sessionContext) {
- Environment mergedEnv = Environment.merge(defaultEnvironment,
sessionContext.getSessionEnv());
- return createExecutionContext(mergedEnv, sessionContext);
- }
-
- /**
- * Create a new {@link ExecutionContext} by using the given environment.
- */
- private ExecutionContext<?> createExecutionContext(Environment
environment, SessionContext sessionContext) {
- try {
- return new ExecutionContext<>(
- environment,
- sessionContext,
- dependencies,
- flinkConfig,
- clusterClientServiceLoader,
- commandLineOptions,
- commandLines);
- } catch (Throwable t) {
- // catch everything such that a configuration does not
crash the executor
- throw new SqlExecutionException("Could not create
execution context.", t);
- }
+ /** Returns ExecutionContext.Builder with given {@link SessionContext}
session context. */
+ private ExecutionContext.Builder
createExecutionContextBuilder(SessionContext sessionContext) {
+ return ExecutionContext.builder(
+ defaultEnvironment,
+ sessionContext,
+ this.dependencies,
+ this.flinkConfig,
+ this.clusterClientServiceLoader,
+ this.commandLineOptions,
+ this.commandLines);
}
@Override
public String openSession(SessionContext sessionContext) throws
SqlExecutionException {
String sessionId = sessionContext.getSessionId();
- ExecutionContext previousContext =
this.contextMap.putIfAbsent(sessionId, createExecutionContext(sessionContext));
+ ExecutionContext previousContext = this.contextMap.putIfAbsent(
Review comment:
And I think it's better to not use `putIfAbsent` in this case. `putIfAbsent`
will eagerly trigger the operation to create whole execution context no matter
whether the session is already exist or not. And I know there will be one more
key lookup if you judge the sessionId is existed before put it into, but it's
more lightweight comparing to initialize a big execution context.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services