Skip to content

Commit

Permalink
add polardb-x parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
agapple committed Jun 13, 2022
1 parent b0517e7 commit f7ab505
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,52 @@ public void test_mariadb_aria() throws Throwable {
SchemaObject table = repository.findTable("test");
Assert.assertTrue(table != null);
}

@Test
public void test_polardb_x() throws Throwable {
SchemaRepository repository = new SchemaRepository(JdbcConstants.MYSQL);
repository.setDefaultSchema("test");

String sql1 = "CREATE TABLE `test1` (\n" + " `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n"
+ " `serialNo` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',\n"
+ " `user_id` int(11) DEFAULT NULL COMMENT '用户id',\n" + " PRIMARY KEY (`id`)\n"
+ ") ENGINE = InnoDB PARTITION BY KEY(`tenant_id`,`id`)\n" + "PARTITIONS 21 tablegroup = `tg_p_msg`";
repository.console(sql1);
SchemaObject table = repository.findTable("test1");
Assert.assertTrue(table != null);


String sql2 = "CREATE TABLE `test2` (\n" + " `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n"
+ " `serialNo` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',\n"
+ " `user_id` int(11) DEFAULT NULL COMMENT '用户id',\n" + " PRIMARY KEY (`id`)\n"
+ ") ENGINE = InnoDB single";
repository.console(sql2);
table = repository.findTable("test2");
Assert.assertTrue(table != null);


String sql3 = "CREATE TABLE `test3` (\n" + " `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n"
+ " `serialNo` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',\n"
+ " `user_id` int(11) DEFAULT NULL COMMENT '用户id',\n" + " PRIMARY KEY (`id`)\n"
+ ") ENGINE = InnoDB locality = 'dn=polardbx-ng28-dn-1,polardbx-ng28-dn-2'";
repository.console(sql3);
table = repository.findTable("test3");
Assert.assertTrue(table != null);

String sql4 = "CREATE TABLE test4(\n" + " order_id int AUTO_INCREMENT primary key,\n"
+ " customer_id int,\n" + " country varchar(64),\n" + " city varchar(64),\n"
+ " order_time datetime not null)\n" + "PARTITION BY LIST COLUMNS(country,city)\n" + "(\n"
+ " PARTITION p1 VALUES IN (('China','Shanghai')) LOCALITY = 'dn=polardbx-ng28-dn-2',\n"
+ " PARTITION p2 VALUES IN (('China','Beijing')) LOCALITY = 'dn=polardbx-ng28-dn-2',\n"
+ " PARTITION p3 VALUES IN (('China','Hangzhou')) ,\n"
+ " PARTITION p4 VALUES IN (('China','Nanjing')) ,\n"
+ " PARTITION p5 VALUES IN (('China','Guangzhou')) ,\n"
+ " PARTITION p6 VALUES IN (('China','Shenzhen')) ,\n"
+ " PARTITION p7 VALUES IN (('China','Wuhan')) ,\n"
+ " PARTITION p8 VALUES IN (('America','New York'))\n"
+ ") LOCALITY = 'dn=polardbx-ng28-dn-0,polardbx-ng28-dn-1';";
repository.console(sql4);
table = repository.findTable("test4");
Assert.assertTrue(table != null);
}
}

0 comments on commit f7ab505

Please sign in to comment.