xuefuz commented on a change in pull request #9049: [FLINK-13176][SQL CLI] 
remember current catalog and database in SQL CLI SessionContext
URL: https://github.com/apache/flink/pull/9049#discussion_r303558641
 
 

 ##########
 File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/ExecutionContext.java
 ##########
 @@ -303,14 +303,24 @@ private EnvironmentInstance() {
                        // register catalogs
                        catalogs.forEach(tableEnv::registerCatalog);
 
-                       Optional<String> potentialCurrentCatalog = 
mergedEnv.getExecution().getCurrentCatalog();
-                       if (potentialCurrentCatalog.isPresent()) {
-                               
tableEnv.useCatalog(potentialCurrentCatalog.get());
+                       // set current catalog
+                       Optional<String> potentialCatalog = Optional.empty();
+                       if (sessionContext.getCurrentCatalog().isPresent()) {
+                               potentialCatalog = 
sessionContext.getCurrentCatalog();
+                       } else if 
(mergedEnv.getExecution().getCurrentCatalog().isPresent()) {
+                               potentialCatalog = 
mergedEnv.getExecution().getCurrentCatalog();
                        }
 
-                       Optional<String> potentialCurrentDatabase = 
mergedEnv.getExecution().getCurrentDatabase();
-                       if (potentialCurrentDatabase.isPresent()) {
-                               
tableEnv.useDatabase(potentialCurrentDatabase.get());
+                       // set current database to default
 
 Review comment:
   This line of comment doesn't seem matching the code below.

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