Skip to content

Commit

Permalink
[Enhancement] Do not display type when table comment is empty (#24803)
Browse files Browse the repository at this point in the history
Fixes #issue

Signed-off-by: Astralidea <[email protected]>
(cherry picked from commit e770adb)

# Conflicts:
#	fe/fe-core/src/test/java/com/starrocks/analysis/ShowCreateMaterializedViewStmtTest.java
#	test/sql/test_default_enable_replicated_storage/R/test_enable_mv
#	test/sql/test_materialized_column/R/test_materialized_column
#	test/sql/test_random_distribution/R/test_random_distribution
  • Loading branch information
Astralidea authored and mergify[bot] committed Jun 7, 2023
1 parent 29c3861 commit 5f791c8
Show file tree
Hide file tree
Showing 6 changed files with 927 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/com/starrocks/catalog/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public String getComment() {
if (!Strings.isNullOrEmpty(comment)) {
return comment;
}
return type.name();
return "";
}

public void setComment(String comment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ public void testShowInternalCatalogConstraints() throws Exception {
Table table = currentState.getDb("test").getTable("mv9");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals("CREATE MATERIALIZED VIEW `mv9`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals("CREATE MATERIALIZED VIEW `mv9` (k1, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"DISTRIBUTED BY HASH(`k1`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
"PROPERTIES (\n" +
Expand Down Expand Up @@ -123,8 +127,12 @@ public void testShowExternalCatalogConstraints() throws Exception {
Table table = currentState.getDb("test").getTable("mv10");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals("CREATE MATERIALIZED VIEW `mv10`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals("CREATE MATERIALIZED VIEW `mv10` (c1, c2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"DISTRIBUTED BY HASH(`c1`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
"PROPERTIES (\n" +
Expand Down Expand Up @@ -166,8 +174,12 @@ public void testShowSimpleCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv1");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv1`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv1` (k1, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"DISTRIBUTED BY HASH(`k1`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
"PROPERTIES (\n" +
Expand All @@ -194,8 +206,12 @@ public void testShowPartitionWithAliasCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv2");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv2`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv2` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (`k3`)\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
Expand Down Expand Up @@ -223,8 +239,12 @@ public void testShowPartitionWithFunctionCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv3");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv3`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv3` (k1, k3)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k1`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
Expand Down Expand Up @@ -253,8 +273,12 @@ public void testShowPartitionWithFunctionAliasCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv4");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv4`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv4` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k3`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
Expand Down Expand Up @@ -288,8 +312,12 @@ public void testShowPartitionWithAllPropertiesCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv5");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv5`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv5` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k3`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH ASYNC START(\"2122-12-31 00:00:00\") EVERY(INTERVAL 1 HOUR)\n" +
Expand Down Expand Up @@ -324,8 +352,12 @@ public void testShowRefreshWithNoStartTimeCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv6");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv6`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv6` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k3`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH ASYNC\n" +
Expand Down Expand Up @@ -360,8 +392,12 @@ public void testShowRefreshWithIntervalCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv7");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv7`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv7` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k3`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH ASYNC EVERY(INTERVAL 1 HOUR)\n" +
Expand Down Expand Up @@ -391,8 +427,12 @@ public void testShowExternalTableCreateMvSql() throws Exception {
Table table = currentState.getDb("test").getTable("mv8");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv8`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `mv8` (l_orderkey, l_partkey, l_shipdate)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 10 \n" +
"REFRESH MANUAL\n" +
"PROPERTIES (\n" +
Expand All @@ -418,8 +458,12 @@ public void testShowCreateDeferredMv() throws Exception {
Table table = currentState.getDb("test").getTable("deferred_mv4");
List<String> createTableStmt = Lists.newArrayList();
GlobalStateMgr.getDdlStmt(table, createTableStmt, null, null, false, true);
<<<<<<< HEAD
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `deferred_mv4`\n" +
"COMMENT \"MATERIALIZED_VIEW\"\n" +
=======
Assert.assertEquals(createTableStmt.get(0), "CREATE MATERIALIZED VIEW `deferred_mv4` (k3, k2)\n" +
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
"PARTITION BY (date_trunc('month', `k3`))\n" +
"DISTRIBUTED BY HASH(`k3`) BUCKETS 10 \n" +
"REFRESH DEFERRED MANUAL\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public void testShowTableStatus() throws Exception {
Assert.assertEquals("0", resultRows.get(0).get(5));
Assert.assertEquals("0", resultRows.get(0).get(6));
Assert.assertEquals("utf8_general_ci", resultRows.get(0).get(14));
Assert.assertEquals("OLAP", resultRows.get(0).get(17));
}

@Test(expected = SemanticException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ create materialized view tvd distributed by hash(k) buckets 10 REFRESH ASYNC as
-- !result
show create materialized view tvd;
-- result:
<<<<<<< HEAD
tvd CREATE MATERIALIZED VIEW `tvd`
COMMENT "MATERIALIZED_VIEW"
=======
tvd CREATE MATERIALIZED VIEW `tvd` (k, sum(v))
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
DISTRIBUTED BY HASH(`k`) BUCKETS 10
REFRESH ASYNC
PROPERTIES (
Expand All @@ -37,8 +41,12 @@ create materialized view tvb distributed by hash(k) buckets 10 REFRESH ASYNC as
-- !result
show create materialized view tvb;
-- result:
<<<<<<< HEAD
tvb CREATE MATERIALIZED VIEW `tvb`
COMMENT "MATERIALIZED_VIEW"
=======
tvb CREATE MATERIALIZED VIEW `tvb` (k, sum(v))
>>>>>>> e770adb8b ([Enhancement] Do not display type when table comment is empty (#24803))
DISTRIBUTED BY HASH(`k`) BUCKETS 10
REFRESH ASYNC
PROPERTIES (
Expand Down
Loading

0 comments on commit 5f791c8

Please sign in to comment.