This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
new a109c09e7b [Cherry-pick](CTAS) Fix CTAS error for use agg column as
first. #12315
a109c09e7b is described below
commit a109c09e7b447d4128410e6273c2794318e133f3
Author: Stalary <[email protected]>
AuthorDate: Sat Sep 3 09:36:55 2022 +0800
[Cherry-pick](CTAS) Fix CTAS error for use agg column as first. #12315
---
.../java/org/apache/doris/catalog/Catalog.java | 6 +--
.../analysis/CreateTableAsSelectStmtTest.java | 47 +++++++++-------------
2 files changed, 21 insertions(+), 32 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
index 83ba31b1e3..2bdf8ebcba 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -3153,11 +3153,7 @@ public class Catalog {
} else {
defaultValue = new DefaultValue(setDefault,
column.getDefaultValue());
}
- // AggregateType.NONE cause the table to change to the
AGGREGATE KEY when analyze is used,
- // cause CURRENT_TIMESTAMP to report an error.
- columnDef = new ColumnDef(name, typeDef, column.isKey(),
-
AggregateType.NONE.equals(column.getAggregationType())
- ? null : column.getAggregationType(),
+ columnDef = new ColumnDef(name, typeDef, column.isKey(),
null,
column.isAllowNull(), defaultValue,
column.getComment());
}
createTableStmt.addColumnDef(columnDef);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
index bf2154c5bd..18674d3a63 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
@@ -112,13 +112,6 @@ public class CreateTableAsSelectStmtTest {
return executor.execute();
}
- @Test
- public void testErrorType() {
- String selectFromDecimal = "create table `test`.`select_decimal_table`
PROPERTIES(\"replication_num\" = \"1\") as select * from
`test`.`decimal_table`";
- ExceptionChecker.expectThrowsWithMsg(AnalysisException.class,
"Unsupported type",
- () -> UtFrameUtils.parseAndAnalyzeStmt(selectFromDecimal,
connectContext));
- }
-
@Test
public void testErrorColumn() {
String selectFromColumn = "create table
`test`.`select_column_table`(test_error) PROPERTIES(\"replication_num\" =
\"1\") as select * from `test`.`varchar_table`";
@@ -132,8 +125,8 @@ public class CreateTableAsSelectStmtTest {
createTableAsSelect(selectFromDecimal);
ShowResultSet showResultSet = showCreateTable("select_varchar");
Assert.assertEquals("CREATE TABLE `select_varchar` (\n" +
- " `userId` varchar(255) NULL COMMENT \"\",\n" +
- " `username` varchar(255) NULL COMMENT \"\"\n" +
+ " `userId` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `username` varchar(255) NOT NULL COMMENT \"\"\n" +
") ENGINE=OLAP\n" +
"DUPLICATE KEY(`userId`)\n" +
"COMMENT \"OLAP\"\n" +
@@ -142,7 +135,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet.getResultRows().get(0).get(1));
+ ");", showResultSet.getResultRows().get(0).get(1));
}
@Test
@@ -160,7 +153,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet1.getResultRows().get(0).get(1));
+ ");", showResultSet1.getResultRows().get(0).get(1));
String selectFromFunction2 = "create table `test`.`select_function_2`
PROPERTIES(\"replication_num\" = \"1\") as select sum(status), sum(status),
sum(status), count(status), count(status) from `test`.`join_table`";
createTableAsSelect(selectFromFunction2);
@@ -179,7 +172,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet2.getResultRows().get(0).get(1));
+ ");", showResultSet2.getResultRows().get(0).get(1));
}
@Test
@@ -197,13 +190,13 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet1.getResultRows().get(0).get(1));
+ ");", 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 = showCreateTable("select_alias_2");
Assert.assertEquals("CREATE TABLE `select_alias_2` (\n" +
- " `alias_name` varchar(255) NULL COMMENT \"\",\n" +
- " `username` varchar(255) NULL COMMENT \"\"\n" +
+ " `alias_name` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `username` varchar(255) NOT NULL COMMENT \"\"\n" +
") ENGINE=OLAP\n" +
"DUPLICATE KEY(`alias_name`)\n" +
"COMMENT \"OLAP\"\n" +
@@ -212,7 +205,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet2.getResultRows().get(0).get(1));
+ ");", showResultSet2.getResultRows().get(0).get(1));
}
@Test
@@ -222,9 +215,9 @@ public class CreateTableAsSelectStmtTest {
createTableAsSelect(selectFromJoin);
ShowResultSet showResultSet = showCreateTable("select_join");
Assert.assertEquals("CREATE TABLE `select_join` (\n" +
- " `userId` varchar(255) NULL COMMENT \"\",\n" +
- " `username` varchar(255) NULL COMMENT \"\",\n" +
- " `status` int(11) NULL COMMENT \"\"\n" +
+ " `userId` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `username` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `status` int(11) NOT NULL COMMENT \"\"\n" +
") ENGINE=OLAP\n" +
"DUPLICATE KEY(`userId`)\n" +
"COMMENT \"OLAP\"\n" +
@@ -233,7 +226,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet.getResultRows().get(0).get(1));
+ ");", showResultSet.getResultRows().get(0).get(1));
}
@Test
@@ -243,9 +236,9 @@ public class CreateTableAsSelectStmtTest {
createTableAsSelect(selectFromName);
ShowResultSet showResultSet = showCreateTable("select_name");
Assert.assertEquals("CREATE TABLE `select_name` (\n" +
- " `user` varchar(255) NULL COMMENT \"\",\n" +
- " `testname` varchar(255) NULL COMMENT \"\",\n" +
- " `userstatus` int(11) NULL COMMENT \"\"\n" +
+ " `user` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `testname` varchar(255) NOT NULL COMMENT \"\",\n" +
+ " `userstatus` int(11) NOT NULL COMMENT \"\"\n" +
") ENGINE=OLAP\n" +
"DUPLICATE KEY(`user`)\n" +
"COMMENT \"OLAP\"\n" +
@@ -254,7 +247,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet.getResultRows().get(0).get(1));
+ ");", showResultSet.getResultRows().get(0).get(1));
}
@Test
@@ -273,7 +266,7 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet.getResultRows().get(0).get(1));
+ ");", showResultSet.getResultRows().get(0).get(1));
}
@Test
@@ -283,7 +276,7 @@ public class CreateTableAsSelectStmtTest {
createTableAsSelect(selectFromName);
ShowResultSet showResultSet = showCreateTable("select_cte");
Assert.assertEquals("CREATE TABLE `select_cte` (\n" +
- " `userId` varchar(255) NULL COMMENT \"\"\n" +
+ " `userId` varchar(255) NOT NULL COMMENT \"\"\n" +
") ENGINE=OLAP\n" +
"DUPLICATE KEY(`userId`)\n" +
"COMMENT \"OLAP\"\n" +
@@ -292,6 +285,6 @@ public class CreateTableAsSelectStmtTest {
"\"replication_allocation\" = \"tag.location.default: 1\",\n" +
"\"in_memory\" = \"false\",\n" +
"\"storage_format\" = \"V2\"\n" +
- ")", showResultSet.getResultRows().get(0).get(1));
+ ");", showResultSet.getResultRows().get(0).get(1));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]