danny0405 commented on a change in pull request #10400: 
[FLINK-13195][sql-client] Add create table support for SqlClient
URL: https://github.com/apache/flink/pull/10400#discussion_r353587989
 
 

 ##########
 File path: 
flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/LocalExecutorITCase.java
 ##########
 @@ -614,6 +614,67 @@ public void testParameterizedTypes() throws Exception {
                executor.closeSession(sessionId);
        }
 
+       @Test
+       public void testCreateTable() throws Exception {
+               final Executor executor = createDefaultExecutor(clusterClient);
+               final SessionContext session = new 
SessionContext("test-session", new Environment());
+               String sessionId = executor.openSession(session);
+               try {
+                       executor.useCatalog(sessionId, "catalog1");
+                       final String ddlTemplate = "create table %s(\n" +
+                                       "  a int,\n" +
+                                       "  b bigint,\n" +
+                                       "  c varchar\n" +
+                                       ") with (\n" +
+                                       "  'connector.type'='filesystem',\n" +
+                                       "  'format.type'='csv',\n" +
+                                       "  'connector.path'='xxx'\n" +
+                                       ")\n";
+                       executor.createTable(sessionId, 
String.format(ddlTemplate, "MyTable1"));
+                       assertEquals(Collections.singletonList("MyTable1"), 
executor.listTables(sessionId));
+
+                       executor.createTable(sessionId, 
String.format(ddlTemplate, "MyTable2"));
+
+                       final List<String> expectedTables = Arrays.asList(
+                                       "MyTable1",
+                                       "MyTable2");
+                       assertEquals(expectedTables, 
executor.listTables(sessionId));
+               } finally {
+                       executor.closeSession(sessionId);
+               }
+       }
+
+       @Test
+       public void testCreateTableWithMultiSession() throws Exception {
+               final Executor executor = createDefaultExecutor(clusterClient);
+               final SessionContext session = new 
SessionContext("test-session", new Environment());
+               String sessionId = executor.openSession(session);
+               try {
+                       executor.useCatalog(sessionId, "catalog1");
+                       executor.setSessionProperty(sessionId, 
"execution.type", "batch");
+                       final String ddlTemplate = "create table %s(\n" +
+                                       "  a int,\n" +
+                                       "  b bigint,\n" +
+                                       "  c varchar\n" +
+                                       ") with (\n" +
+                                       "  'connector.type'='filesystem',\n" +
+                                       "  'format.type'='csv',\n" +
+                                       "  'connector.path'='xxx',\n" +
+                                       "  'update-mode'='append'\n" +
+                                       ")\n";
+                       executor.createTable(sessionId, 
String.format(ddlTemplate, "MyTable1"));
+                       // change the session property to trigger `new 
ExecutionContext`.
+                       executor.setSessionProperty(sessionId, 
"execution.restart-strategy.failure-rate-interval", "12345");
+                       executor.useCatalog(sessionId, "catalog1");
 
 Review comment:
   I think we still need to show the created tables in the original session.

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