KurtYoung commented on a change in pull request #10270: 
[FLINK-14672][sql-client] Make Executor stateful in sql client
URL: https://github.com/apache/flink/pull/10270#discussion_r349420525
 
 

 ##########
 File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
 ##########
 @@ -200,69 +277,98 @@ public void start() {
        }
 
        @Override
-       public List<String> listCatalogs(SessionContext session) throws 
SqlExecutionException {
-               final ExecutionContext<?> context = 
getOrCreateExecutionContext(session);
+       public void resetSessionProperties(String sessionId) throws 
SqlExecutionException {
+               // Renew the ExecutionContext by using the default environment.
+               this.contextMap.put(sessionId, 
createExecutionContext(defaultEnvironment));
+       }
 
-               final TableEnvironment tableEnv = context
-                       .createEnvironmentInstance()
-                       .getTableEnvironment();
+       @Override
+       public void setSessionProperty(String sessionId, String key, String 
value) throws SqlExecutionException {
+               Environment env = 
getExecutionContext(sessionId).getEnvironment();
+               Environment newEnv = Environment.enrich(env, 
ImmutableMap.of(key, value), ImmutableMap.of());
+               // Renew the ExecutionContext by merging the default 
environment and new environment.
+               this.contextMap.put(sessionId, 
createExecutionContext(defaultEnvironment, newEnv));
+       }
 
-               return context.wrapClassLoader(() -> 
Arrays.asList(tableEnv.listCatalogs()));
+       @Override
+       public void addView(String sessionId, String name, String query) throws 
SqlExecutionException {
+               Environment env = 
getExecutionContext(sessionId).getEnvironment();
+               Environment newEnv = Environment.enrich(
+                       env,
+                       ImmutableMap.of(),
+                       ImmutableMap.of(name, ViewEntry.create(name, query)));
+               // Renew the ExecutionContext.
+               this.contextMap.put(sessionId, 
createExecutionContext(defaultEnvironment, newEnv));
 
 Review comment:
   ditto

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

Reply via email to