snuyanzin commented on code in PR #28222:
URL: https://github.com/apache/flink/pull/28222#discussion_r3287883055
##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java:
##########
@@ -1050,6 +1050,93 @@ void testCreateTable() {
sql(sql).ok(expected);
}
+ @Test
+ void testCreateTableUsingConnection() {
+ final String sql =
+ "CREATE TABLE orders (\n"
+ + " order_id INT,\n"
+ + " customer_id INT,\n"
+ + " amount DECIMAL(10, 2)\n"
+ + ") USING CONNECTION mycat.mydb.mysql_prod\n"
+ + "WITH (\n"
+ + " 'connector' = 'jdbc',\n"
+ + " 'tables' = 'orders'\n"
+ + ")";
+ final String expected =
+ "CREATE TABLE `ORDERS` (\n"
+ + " `ORDER_ID` INTEGER,\n"
+ + " `CUSTOMER_ID` INTEGER,\n"
+ + " `AMOUNT` DECIMAL(10, 2)\n"
+ + ")\n"
+ + "USING CONNECTION `MYCAT`.`MYDB`.`MYSQL_PROD`\n"
+ + "WITH (\n"
+ + " 'connector' = 'jdbc',\n"
+ + " 'tables' = 'orders'\n"
+ + ")";
+ sql(sql).ok(expected);
+ }
+
+ @Test
+ void testCreateTableUsingConnectionWithPartitionAndDistribution() {
+ final String sql =
+ "CREATE TABLE tbl1 (\n"
+ + " a bigint,\n"
+ + " h varchar,\n"
+ + " b varchar\n"
+ + ")\n"
+ + "DISTRIBUTED BY HASH(a) INTO 3 BUCKETS\n"
+ + "PARTITIONED BY (a, h)\n"
+ + "USING CONNECTION cat1.db1.conn1\n"
+ + "WITH (\n"
+ + " 'connector' = 'jdbc'\n"
+ + ")";
+ final String expected =
+ "CREATE TABLE `TBL1` (\n"
+ + " `A` BIGINT,\n"
+ + " `H` VARCHAR,\n"
+ + " `B` VARCHAR\n"
+ + ")\n"
+ + "DISTRIBUTED BY HASH(`A`) INTO 3 BUCKETS\n"
+ + "PARTITIONED BY (`A`, `H`)\n"
+ + "USING CONNECTION `CAT1`.`DB1`.`CONN1`\n"
+ + "WITH (\n"
+ + " 'connector' = 'jdbc'\n"
+ + ")";
+ sql(sql).ok(expected);
+ }
+
+ @Test
+ void testCreateTableAsWithUsingConnectionFails() {
+ final String sql =
Review Comment:
to be on the safe side can we also add a test for `REPLACE TABLE AS`?
--
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]