Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](DDL) not set table type as default comment when create table #35855

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public String getComment(boolean escapeQuota) {
}
return SqlUtils.escapeQuota(comment);
}
return type.name();
return "";
}

public void setComment(String comment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void alterTableModifyComment() throws Exception {
// empty comment
stmt = "alter table test.tbl5 modify comment ''";
alterTable(stmt, false);
Assert.assertEquals("OLAP", tbl.getComment());
Assert.assertEquals("", tbl.getComment());

// empty column comment
stmt = "alter table test.tbl5 modify column k1 comment '', modify column v1 comment 'v111'";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public void testDecimal() throws Exception {
+ "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"
Expand All @@ -114,7 +113,6 @@ public void testDecimal() throws Exception {
+ " `__sum_0` DECIMAL(38, 2) NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__sum_0`)\n"
+ "COMMENT 'OLAP'\n"
+ "DISTRIBUTED BY HASH(`__sum_0`) BUCKETS 10\n"
+ "PROPERTIES (\n"
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
Expand Down Expand Up @@ -176,7 +174,6 @@ public void testVarchar() throws Exception {
+ " `username` VARCHAR(255) 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"
Expand Down Expand Up @@ -205,7 +202,6 @@ public void testFunction() throws Exception {
+ " `__count_0` BIGINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__count_0`)\n"
+ "COMMENT 'OLAP'\n"
+ "DISTRIBUTED BY HASH(`__count_0`) BUCKETS 10\n"
+ "PROPERTIES (\n"
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
Expand Down Expand Up @@ -236,7 +232,6 @@ public void testFunction() throws Exception {
+ " `__count_4` BIGINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__sum_0`, `__sum_1`, `__sum_2`)\n"
+ "COMMENT 'OLAP'\n"
+ "DISTRIBUTED BY HASH(`__sum_0`) BUCKETS 10\n"
+ "PROPERTIES (\n"
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
Expand Down Expand Up @@ -264,7 +259,6 @@ public void testAlias() throws Exception {
+ " `amount` BIGINT 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"
Expand All @@ -288,7 +282,6 @@ public void testAlias() throws Exception {
+ " `username` VARCHAR(255) 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"
Expand Down Expand Up @@ -319,7 +312,6 @@ public void testJoin() throws Exception {
+ " `status` INT 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"
Expand Down Expand Up @@ -347,7 +339,6 @@ public void testJoin() throws Exception {
+ " `status` INT 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"
Expand Down Expand Up @@ -379,7 +370,6 @@ public void testName() throws Exception {
+ " `userstatus` INT 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"
Expand Down Expand Up @@ -408,7 +398,6 @@ public void testUnion() throws Exception {
+ " `userId` VARCHAR(255) 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"
Expand Down Expand Up @@ -436,7 +425,6 @@ public void testCte() throws Exception {
+ " `userId` VARCHAR(255) 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"
Expand All @@ -460,7 +448,6 @@ public void testCte() throws Exception {
+ " `id` TINYINT 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"
Expand Down Expand Up @@ -489,7 +476,6 @@ public void testPartition() throws Exception {
+ " `username` VARCHAR(255) 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"
Expand Down Expand Up @@ -521,7 +507,6 @@ public void testDefaultTimestamp() throws Exception {
+ " 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"
Expand Down Expand Up @@ -550,7 +535,6 @@ public void testAggValue() throws Exception {
+ " `username` VARCHAR(255) 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"
Expand Down Expand Up @@ -580,7 +564,6 @@ public void testUseKeyType() throws Exception {
+ " `username` VARCHAR(255) 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"
Expand Down Expand Up @@ -635,7 +618,6 @@ public void testQuerySchema() throws Exception {
+ " `k2` INT 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"
Expand All @@ -657,7 +639,6 @@ public void testQuerySchema() throws Exception {
+ " `k2` INT 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"
Expand Down Expand Up @@ -693,7 +674,6 @@ public void testVarcharLength() throws Exception {
+ " `userId` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__literal_0`)\n"
+ "COMMENT 'OLAP'\n"
+ "DISTRIBUTED BY HASH(`__literal_0`) BUCKETS 10\n"
+ "PROPERTIES (\n"
+ "\"replication_allocation\" = \"tag.location.default: 1\",\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !test_sql --
test_decimal_boolean_view CREATE VIEW `test_decimal_boolean_view` COMMENT 'VIEW' AS SELECT `id` AS `id`, `c1` AS `c1`, `c2` AS `c2` FROM `regression_test_datatype_p0_scalar_types`.`test_decimal_boolean` WHERE (0.0 = CAST(`c1` AS DECIMALV3(2, 1))) AND (CAST(`c2` AS DECIMALV3(6, 1)) = 1.0); utf8mb4 utf8mb4_0900_bin
test_decimal_boolean_view CREATE VIEW `test_decimal_boolean_view` AS SELECT `id` AS `id`, `c1` AS `c1`, `c2` AS `c2` FROM `regression_test_datatype_p0_scalar_types`.`test_decimal_boolean` WHERE (0.0 = CAST(`c1` AS DECIMALV3(2, 1))) AND (CAST(`c2` AS DECIMALV3(6, 1)) = 1.0); utf8mb4 utf8mb4_0900_bin

-- !test_union --
0
1
0.0
1.0

2 changes: 1 addition & 1 deletion regression-test/data/ddl_p0/test_create_view.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
3 [-1, 20, 0] [0, 1, 0]

-- !test_view_6 --
v1 CREATE VIEW `v1` COMMENT 'VIEW' AS SELECT\n error_code, \n 1, \n 'string', \n now(), \n dayofyear(op_time), \n cast (source AS BIGINT), \n min(`timestamp`) OVER (\n ORDER BY \n op_time DESC ROWS BETWEEN UNBOUNDED PRECEDING\n AND 1 FOLLOWING\n ), \n 1 > 2,\n 2 + 3,\n 1 IN (1, 2, 3, 4), \n remark LIKE '%like', \n CASE WHEN remark = 's' THEN 1 ELSE 2 END,\n TRUE | FALSE \n FROM \n `internal`.`regression_test_ddl_p0`.`view_column_name_test`;
v1 CREATE VIEW `v1` AS SELECT\n error_code, \n 1, \n 'string', \n now(), \n dayofyear(op_time), \n cast (source AS BIGINT), \n min(`timestamp`) OVER (\n ORDER BY \n op_time DESC ROWS BETWEEN UNBOUNDED PRECEDING\n AND 1 FOLLOWING\n ), \n 1 > 2,\n 2 + 3,\n 1 IN (1, 2, 3, 4), \n remark LIKE '%like', \n CASE WHEN remark = 's' THEN 1 ELSE 2 END,\n TRUE | FALSE \n FROM \n `internal`.`regression_test_ddl_p0`.`view_column_name_test`;

Loading
Loading