snuyanzin commented on code in PR #28385:
URL: https://github.com/apache/flink/pull/28385#discussion_r3840866384


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlDdlToOperationConverterTest.java:
##########
@@ -658,6 +661,61 @@ void testCreateTableValidDistribution() {
                                                         
Collections.singletonList("a"), null)))));
     }
 
+    @Test
+    void testCreateTableWithConnection() {
+        final String sql =
+                "CREATE TABLE derivedTable(\n"
+                        + "  a INT\n"
+                        + ")\n"
+                        + "USING CONNECTION mycat.mydb.myconn";
+        Operation operation = parseAndConvert(sql);
+        assertThat(operation).isInstanceOf(CreateTableOperation.class);
+        CreateTableOperation op = (CreateTableOperation) operation;
+        assertThat(op.getCatalogTable().getConnection())
+                .hasValue(UnresolvedIdentifier.of("mycat", "mydb", "myconn"));
+    }
+
+    @Test
+    void testCreateTableWithoutConnection() {
+        final String sql = "CREATE TABLE derivedTable(\n" + "  a INT\n" + ")";
+        Operation operation = parseAndConvert(sql);
+        assertThat(operation).isInstanceOf(CreateTableOperation.class);
+        CreateTableOperation op = (CreateTableOperation) operation;
+        assertThat(op.getCatalogTable().getConnection()).isEmpty();
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"mycat....mydb....myconn", ".", "...", ".2.2."})
+    void testCreateTableWithMalformedConnectionNameFailsToParse(String 
connectionName) {
+        final String sql = "CREATE TABLE derivedTable(a INT) USING CONNECTION 
" + connectionName;
+        assertThatThrownBy(() -> 
parseAndConvert(sql)).isInstanceOf(SqlParserException.class);
+    }
+
+    @Test
+    void testCreateTableWithTooManyConnectionNameParts() {
+        final String sql =
+                "CREATE TABLE derivedTable(a INT) USING CONNECTION 
mycat.mydb.mygroup.myconn";
+        assertThatThrownBy(() -> parseAndConvert(sql))
+                .isInstanceOf(ValidationException.class)
+                .hasMessageContaining("Object identifier must consist of 1 to 
3 parts.");
+    }
+
+    @Test
+    void testCreateTableWithWhitespaceOnlyConnectionNamePart() {
+        final String sql = "CREATE TABLE derivedTable(a INT) USING CONNECTION 
mycat.`   `.myconn";
+        assertThatThrownBy(() -> parseAndConvert(sql))
+                .isInstanceOf(ValidationException.class)
+                .hasMessageContaining(
+                        "Parts of the object identifier are null or 
whitespace-only.");
+    }
+
+    @Test
+    void testCreateTableWithUnicodeConnectionName() {
+        final String sql = "CREATE TABLE derivedTable(a INT) USING CONNECTION 
`😍.😍`";

Review Comment:
   nit: can we have a test with multibyte symbols then?



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