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


##########
flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/service/SqlGatewayServiceITCase.java:
##########
@@ -157,6 +169,80 @@ 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
+        verifyConfigureSession(sessionHandle, "SET 'key1' = 'value1';");
+        Map<String, String> config = new HashMap<>();
+        config.put("key1", "value1");
+        
assertThat(service.getSessionConfig(sessionHandle)).containsAllEntriesOf(config);
+
+        verifyConfigureSession(sessionHandle, "RESET 'key1';");
+        
assertThat(service.getSessionConfig(sessionHandle)).doesNotContainEntry("key1", 
"value1");
+
+        // CREATE & USE & ALTER & DROP
+        verifyConfigureSession(
+                sessionHandle,
+                "CREATE CATALOG mycat with ('type' = 'generic_in_memory', 
'default-database' = 'db');");
+
+        verifyConfigureSession(sessionHandle, "USE CATALOG mycat;");
+        
assertThat(service.getCurrentCatalog(sessionHandle)).isEqualTo("mycat");
+
+        verifyConfigureSession(
+                sessionHandle, "CREATE TABLE db.tbl (score INT) WITH 
('connector' = 'datagen');");
+
+        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));
+
+        verifyConfigureSession(sessionHandle, "ALTER TABLE db.tbl RENAME TO 
tbl1;");
+        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);
+        verifyConfigureSession(sessionHandle, "DROP CATALOG mycat;");
+        
assertThat(service.listCatalogs(sessionHandle)).doesNotContain("mycat");
+
+        // LOAD & UNLOAD MODULE
+        verifyConfigureSession(sessionHandle, "LOAD MODULE dummy;");
+
+        TableEnvironmentInternal tableEnv =
+                
service.getSession(sessionHandle).createExecutor().getTableEnvironment();
+        assertThat(
+                        CollectionUtil.iteratorToList(
+                                tableEnv.executeSql("SHOW FULL 
MODULES;").collect()))
+                .contains(Row.of("dummy", true));
+
+        verifyConfigureSession(sessionHandle, "UNLOAD MODULE dummy;");
+        assertThat(
+                        CollectionUtil.iteratorToList(
+                                tableEnv.executeSql("SHOW FULL 
MODULES;").collect()))
+                .isEqualTo(Collections.singletonList(Row.of("core", true)));
+
+        // ADD JAR
+        String udfClassName = GENERATED_LOWER_UDF_CLASS + new 
Random().nextInt(50);
+        String jarPath =
+                UserClassLoaderJarTestUtils.createJarFile(
+                                new File(tmpDir.toUri()),
+                                "test-add-jar.jar",
+                                udfClassName,
+                                String.format(GENERATED_LOWER_UDF_CODE, 
udfClassName))
+                        .toURI()
+                        .toString();
+        verifyConfigureSession(sessionHandle, String.format("ADD JAR '%s';", 
jarPath));
+
+        assertThat(CollectionUtil.iteratorToList(tableEnv.executeSql("SHOW 
JARS;").collect()))
+                .isEqualTo(Collections.singletonList(Row.of(new 
Path(jarPath).getPath())));

Review Comment:
   Mentioned above.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to