yuzelin commented on code in PR #21133:
URL: https://github.com/apache/flink/pull/21133#discussion_r1039581297


##########
flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/service/SqlGatewayServiceITCase.java:
##########
@@ -157,6 +168,83 @@ public void testOpenSessionWithEnvironment() throws 
Exception {
         assertThat(tableEnv.listModules()).contains(moduleName);
     }
 
+    @Test
+    public void testConfigureSessionWithLegalStatement(@TempDir 
java.nio.file.Path tmpDir)
+            throws Exception {
+        SessionHandle sessionHandle = 
service.openSession(defaultSessionEnvironment);
+
+        // SET & RESET
+        service.configureSession(sessionHandle, "SET 'key1' = 'value1';", 0);
+        Map<String, String> config = new HashMap<>();
+        config.put("key1", "value1");
+        
assertThat(service.getSessionConfig(sessionHandle)).containsAllEntriesOf(config);
+
+        service.configureSession(sessionHandle, "RESET 'key1';", 0);
+        
assertThat(service.getSessionConfig(sessionHandle)).doesNotContainEntry("key1", 
"value1");
+
+        // CREATE & USE & ALTER & DROP
+        service.configureSession(
+                sessionHandle,
+                "CREATE CATALOG mycat with ('type' = 'generic_in_memory', 
'default-database' = 'db');",
+                0);
+
+        service.configureSession(sessionHandle, "USE CATALOG mycat;", 0);
+        
assertThat(service.getCurrentCatalog(sessionHandle)).isEqualTo("mycat");
+
+        service.configureSession(
+                sessionHandle,
+                "CREATE TABLE db.tbl (score INT) WITH ('connector' = 
'datagen');",
+                0);
+
+        Set<TableKind> tableKinds = new HashSet<>();
+        tableKinds.add(TableKind.TABLE);
+        assertThat(service.listTables(sessionHandle, "mycat", "db", 
tableKinds))
+                .contains(
+                        new TableInfo(ObjectIdentifier.of("mycat", "db", 
"tbl"), TableKind.TABLE));
+
+        service.configureSession(sessionHandle, "ALTER TABLE db.tbl RENAME TO 
tbl1;", 0);
+        assertThat(service.listTables(sessionHandle, "mycat", "db", 
tableKinds))
+                .doesNotContain(
+                        new TableInfo(ObjectIdentifier.of("mycat", "db", 
"tbl"), TableKind.TABLE))
+                .contains(
+                        new TableInfo(ObjectIdentifier.of("mycat", "db", 
"tbl1"), TableKind.TABLE));
+
+        service.configureSession(sessionHandle, "USE CATALOG 
default_catalog;", 0);
+        service.configureSession(sessionHandle, "DROP CATALOG mycat;", 0);
+        
assertThat(service.listCatalogs(sessionHandle)).doesNotContain("mycat");
+
+        // LOAD & UNLOAD MODULE
+        service.configureSession(sessionHandle, "LOAD MODULE dummy;", 0);
+
+        TableEnvironmentInternal tableEnv =
+                
service.getSession(sessionHandle).createExecutor().getTableEnvironment();
+        assertThat(
+                        CollectionUtil.iteratorToList(

Review Comment:
   Sure.



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

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to