|
|
|
|
@ -82,12 +82,20 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
String selectFromDecimal = "create table `test`.`select_decimal_table` PROPERTIES(\"replication_num\" = \"1\") "
|
|
|
|
|
+ "as select * from `test`.`decimal_table`";
|
|
|
|
|
createTableAsSelect(selectFromDecimal);
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_decimal_table` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_decimal_table` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `amount_decimal` decimal(10, 2) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\"," + "\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showCreateTableByName("select_decimal_table").getResultRows().get(0).get(1));
|
|
|
|
|
String selectFromDecimal1 =
|
|
|
|
|
"create table `test`.`select_decimal_table_1` PROPERTIES(\"replication_num\" = \"1\") "
|
|
|
|
|
@ -104,12 +112,19 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1));
|
|
|
|
|
} else {
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `select_decimal_table_1` (\n" + " `_col0` decimal(27, 9) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
"CREATE TABLE `select_decimal_table_1` (\n"
|
|
|
|
|
+ " `_col0` decimal(27, 9) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n" + "\"storage_format\" = \"V2\","
|
|
|
|
|
+ "\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -130,11 +145,20 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ "as select * from `test`.`varchar_table`";
|
|
|
|
|
createTableAsSelect(selectFromVarchar);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("select_varchar");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_varchar` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_varchar` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -145,11 +169,19 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(selectFromFunction1);
|
|
|
|
|
ShowResultSet showResultSet1 = showCreateTableByName("select_function_1");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `select_function_1` (\n" + " `_col0` bigint(20) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`)\n" + "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n" + "\"storage_format\" = \"V2\""
|
|
|
|
|
+ ",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
"CREATE TABLE `select_function_1` (\n"
|
|
|
|
|
+ " `_col0` bigint(20) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
|
|
|
|
|
String selectFromFunction2 = "create table `test`.`select_function_2` PROPERTIES(\"replication_num\" = \"1\") "
|
|
|
|
|
@ -158,13 +190,23 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(selectFromFunction2);
|
|
|
|
|
ShowResultSet showResultSet2 = showCreateTableByName("select_function_2");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `select_function_2` (\n" + " `_col0` bigint(20) NULL,\n" + " `_col1` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col2` bigint(20) NULL,\n" + " `_col3` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col4` bigint(20) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`, `_col1`, `_col2`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
"CREATE TABLE `select_function_2` (\n"
|
|
|
|
|
+ " `_col0` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col1` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col2` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col3` bigint(20) NULL,\n"
|
|
|
|
|
+ " `_col4` bigint(20) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`_col0`, `_col1`, `_col2`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`_col0`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet2.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -174,20 +216,37 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ "as select count(*) as amount from `test`.`varchar_table`";
|
|
|
|
|
createTableAsSelect(selectAlias1);
|
|
|
|
|
ShowResultSet showResultSet1 = showCreateTableByName("select_alias_1");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_alias_1` (\n" + " `amount` bigint(20) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`amount`)\n" + "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`amount`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n" + "\"storage_format\" = \"V2\","
|
|
|
|
|
+ "\n\"disable_auto_compaction\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_alias_1` (\n"
|
|
|
|
|
+ " `amount` bigint(20) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`amount`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`amount`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");", showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
String selectAlias2 = "create table `test`.`select_alias_2` PROPERTIES(\"replication_num\" = \"1\") "
|
|
|
|
|
+ "as select userId as alias_name, username from `test`.`varchar_table`";
|
|
|
|
|
createTableAsSelect(selectAlias2);
|
|
|
|
|
ShowResultSet showResultSet2 = showCreateTableByName("select_alias_2");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_alias_2` (\n" + " `alias_name` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`alias_name`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`alias_name`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_alias_2` (\n"
|
|
|
|
|
+ " `alias_name` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`alias_name`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`alias_name`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet2.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -198,26 +257,43 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ "join `test`.`join_table` jt on vt.userId=jt.userId";
|
|
|
|
|
createTableAsSelect(selectFromJoin);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("select_join");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_join` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_join` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL,\n"
|
|
|
|
|
+ " `status` int(11) NOT NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ " `status` int(11) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
String selectFromJoin1 = "create table `test`.`select_join1` PROPERTIES(\"replication_num\" = \"1\") "
|
|
|
|
|
+ "as select vt.userId as userId1, jt.userId as userId2, vt.username, jt.status "
|
|
|
|
|
+ "from `test`.`varchar_table` vt " + "join `test`.`join_table` jt on vt.userId=jt.userId";
|
|
|
|
|
createTableAsSelect(selectFromJoin1);
|
|
|
|
|
ShowResultSet showResultSet1 = showCreateTableByName("select_join1");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_join1` (\n" + " `userId1` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `userId2` text NOT NULL,\n" + " `username` text NOT NULL,\n"
|
|
|
|
|
+ " `status` int(11) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId1`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`userId1`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_join1` (\n"
|
|
|
|
|
+ " `userId1` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `userId2` text NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL,\n"
|
|
|
|
|
+ " `status` int(11) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId1`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId1`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -229,13 +305,21 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ "join `test`.`join_table` jt on vt.userId=jt.userId";
|
|
|
|
|
createTableAsSelect(selectFromName);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("select_name");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_name` (\n" + " `user` varchar(65533) NOT NULL,\n"
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_name` (\n"
|
|
|
|
|
+ " `user` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `testname` text NOT NULL,\n"
|
|
|
|
|
+ " `userstatus` int(11) NOT NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`user`)\n" + "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`user`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ " `userstatus` int(11) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`user`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`user`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -246,12 +330,19 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(selectFromName);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("select_union");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `select_union` (\n" + " `userId` varchar(65533) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
"CREATE TABLE `select_union` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n" + "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\""
|
|
|
|
|
+ " = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");", showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -261,21 +352,37 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(selectFromCte);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("select_cte");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `select_cte` (\n" + " `userId` varchar(65533) NOT NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
"CREATE TABLE `select_cte` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
String selectFromCteAndUnion = "create table `test`.`select_cte_union` PROPERTIES(\"replication_num\" = \"1\")"
|
|
|
|
|
+ "as with source_data as (select 1 as id union all select 2 as id) select * from source_data;";
|
|
|
|
|
createTableAsSelect(selectFromCteAndUnion);
|
|
|
|
|
ShowResultSet showResultSet1 = showCreateTableByName("select_cte_union");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_cte_union` (\n" + " `id` tinyint(4) NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`id`)\n" + "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`id`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n" + "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n" + "\"storage_format\" = \"V2\","
|
|
|
|
|
+ "\n\"disable_auto_compaction\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `select_cte_union` (\n"
|
|
|
|
|
+ " `id` tinyint(4) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`id`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`id`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");", showResultSet1.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -285,13 +392,22 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ "PROPERTIES (\"replication_num\" = \"1\") as " + "select * from `test`.`varchar_table`;";
|
|
|
|
|
createTableAsSelect(selectFromPartition);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("selectPartition");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `selectPartition` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "PARTITION BY LIST(`userId`)\n"
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `selectPartition` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "PARTITION BY LIST(`userId`)\n"
|
|
|
|
|
+ "(PARTITION p1 VALUES IN (\"CA\",\"GB\",\"US\",\"ZH\"))\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -301,12 +417,20 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
+ " as select * from `test`.`default_timestamp_table`";
|
|
|
|
|
createTableAsSelect(createSql);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("test_default_timestamp");
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `test_default_timestamp` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
Assertions.assertEquals("CREATE TABLE `test_default_timestamp` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `date` datetime NULL DEFAULT CURRENT_TIMESTAMP\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -317,11 +441,19 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(createSql);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("test_agg_value");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `test_agg_value` (\n" + " `username` varchar(65533) NOT NULL\n" + ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`username`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`username`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
"CREATE TABLE `test_agg_value` (\n"
|
|
|
|
|
+ " `username` varchar(65533) NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`username`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`username`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -332,11 +464,20 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
createTableAsSelect(createSql);
|
|
|
|
|
ShowResultSet showResultSet = showCreateTableByName("test_use_key_type");
|
|
|
|
|
Assertions.assertEquals(
|
|
|
|
|
"CREATE TABLE `test_use_key_type` (\n" + " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n" + ") ENGINE=OLAP\n" + "UNIQUE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n" + "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n" + "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n" + "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
"CREATE TABLE `test_use_key_type` (\n"
|
|
|
|
|
+ " `userId` varchar(65533) NOT NULL,\n"
|
|
|
|
|
+ " `username` text NOT NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "UNIQUE KEY(`userId`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`userId`) BUCKETS 10\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
showResultSet.getResultRows().get(0).get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -371,20 +512,36 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
|
|
|
|
|
Env.getDdlStmt(tbl, createTableStmts, null, null, false, true, -1L);
|
|
|
|
|
createStmts.add(createTableStmts.get(0));
|
|
|
|
|
if (tbl.getName().equals("qs1")) {
|
|
|
|
|
Assert.assertEquals("CREATE TABLE `qs1` (\n" + " `k1` int(11) NULL,\n" + " `k2` int(11) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n" + "DUPLICATE KEY(`k1`, `k2`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`k1`) BUCKETS 1\n" + "PROPERTIES (\n"
|
|
|
|
|
Assert.assertEquals("CREATE TABLE `qs1` (\n"
|
|
|
|
|
+ " `k1` int(11) NULL,\n"
|
|
|
|
|
+ " `k2` int(11) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`k1`, `k2`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`k1`) BUCKETS 1\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
createTableStmts.get(0));
|
|
|
|
|
} else {
|
|
|
|
|
Assert.assertEquals("CREATE TABLE `qs2` (\n" + " `k1` int(11) NULL,\n" + " `k2` int(11) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n" + "DUPLICATE KEY(`k1`, `k2`)\n" + "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`k1`) BUCKETS 1\n" + "PROPERTIES (\n"
|
|
|
|
|
Assert.assertEquals("CREATE TABLE `qs2` (\n"
|
|
|
|
|
+ " `k1` int(11) NULL,\n"
|
|
|
|
|
+ " `k2` int(11) NULL\n"
|
|
|
|
|
+ ") ENGINE=OLAP\n"
|
|
|
|
|
+ "DUPLICATE KEY(`k1`, `k2`)\n"
|
|
|
|
|
+ "COMMENT 'OLAP'\n"
|
|
|
|
|
+ "DISTRIBUTED BY HASH(`k1`) BUCKETS 1\n"
|
|
|
|
|
+ "PROPERTIES (\n"
|
|
|
|
|
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
|
|
|
|
|
+ "\"in_memory\" = \"false\",\n"
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");",
|
|
|
|
|
+ "\"storage_format\" = \"V2\",\n"
|
|
|
|
|
+ "\"light_schema_change\" = \"true\",\n"
|
|
|
|
|
+ "\"disable_auto_compaction\" = \"false\"\n"
|
|
|
|
|
+ ");",
|
|
|
|
|
createTableStmts.get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|