This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 2234217e829 branch-2.1: [fix](sql) Fix error for show create table
column comment #44958 (#45172)
2234217e829 is described below
commit 2234217e82999d708e39dd81b0417eac7ff9313c
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Dec 9 18:32:59 2024 +0800
branch-2.1: [fix](sql) Fix error for show create table column comment
#44958 (#45172)
Cherry-picked from #44958
Co-authored-by: Uniqueyou <[email protected]>
---
.../src/main/java/org/apache/doris/catalog/Column.java | 2 +-
.../org/apache/doris/analysis/ShowCreateTableStmtTest.java | 14 ++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
index 7e549e5dffd..7d750dc9970 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
@@ -819,7 +819,7 @@ public class Column implements Writable,
GsonPostProcessable {
sb.append(" ON UPDATE ").append(defaultValue).append("");
}
if (StringUtils.isNotBlank(comment)) {
- sb.append(" COMMENT '").append(getComment(true)).append("'");
+ sb.append(" COMMENT \"").append(getComment(true)).append("\"");
}
return sb.toString();
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java
index 353fbad9fab..0faf4a8f34e 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java
@@ -32,7 +32,7 @@ public class ShowCreateTableStmtTest extends
TestWithFeService {
createDatabase("test");
useDatabase("test");
createTable("create table table1\n"
- + "(k1 int comment 'test column k1', k2 int comment 'test
column k2') comment 'test table1' "
+ + "(k1 int comment 'test column k1', k2 int comment 'test
column k2', `timestamp` DATE NOT NULL COMMENT '[''0000-01-01'',
''9999-12-31'']') comment 'test table1' "
+ "PARTITION BY RANGE(`k1`)\n"
+ "(\n"
+ " PARTITION `p01` VALUES LESS THAN (\"10\"),\n"
@@ -48,10 +48,20 @@ public class ShowCreateTableStmtTest extends
TestWithFeService {
String sql = "show create table table1";
ShowResultSet showResultSet = showCreateTable(sql);
String showSql = showResultSet.getResultRows().get(0).get(1);
- Assertions.assertTrue(showSql.contains("`k1` int NULL COMMENT 'test
column k1'"));
+ Assertions.assertTrue(showSql.contains("`k1` int NULL COMMENT \"test
column k1\""));
Assertions.assertTrue(showSql.contains("COMMENT 'test table1'"));
}
+ @Test
+ public void testColumnComment() throws Exception {
+ String sql = "show create table table1";
+ ShowResultSet showResultSet = showCreateTable(sql);
+ String showSql = showResultSet.getResultRows().get(0).get(1);
+ Assertions.assertTrue(showSql.contains("`k1` int NULL COMMENT \"test
column k1\""));
+ Assertions.assertTrue(showSql.contains("`k2` int NULL COMMENT \"test
column k2\""));
+ Assertions.assertTrue(showSql.contains("`timestamp` date NOT NULL
COMMENT \"['0000-01-01', '9999-12-31']\""));
+ }
+
@Test
public void testBrief() throws Exception {
String sql = "show brief create table table1";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]