This is an automated email from the ASF dual-hosted git repository. stalary pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new f2aa87d797 Add ctas support config key type ut and doc. (#12327) f2aa87d797 is described below commit f2aa87d7979b997b6fb19817fa066320b37a1989 Author: Stalary <stal...@163.com> AuthorDate: Tue Sep 6 09:16:02 2022 +0800 Add ctas support config key type ut and doc. (#12327) --- .../Create/CREATE-TABLE-AS-SELECT.md | 11 ++++++++++- .../Create/CREATE-TABLE-AS-SELECT.md | 11 ++++++++++- .../doris/analysis/CreateTableAsSelectStmtTest.java | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md b/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md index e72329e8fa..7498fdaa98 100644 --- a/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md +++ b/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md @@ -38,13 +38,22 @@ grammar: ```sql CREATE TABLE table_name [( column_name_list )] -opt_engine opt_partition opt_properties KW_AS query_stmt + opt_engine:engineName + opt_keys:keys + opt_comment:tableComment + opt_partition:partition + opt_distribution:distribution + opt_rollup:index + opt_properties:tblProperties + opt_ext_properties:extProperties + KW_AS query_stmt:query_def ``` illustrate: - The user needs to have`SELECT`permission for the source table and`CREATE`permission for the target database - After a table is created, data is imported. If the import fails, the table is deleted +- You can specify the key type. The default key type is `Duplicate Key` ### Example diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md index d10d252ff7..82938f9315 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md @@ -38,13 +38,22 @@ CREATE TABLE AS SELECT ```sql CREATE TABLE table_name [( column_name_list )] -opt_engine opt_partition opt_properties KW_AS query_stmt + opt_engine:engineName + opt_keys:keys + opt_comment:tableComment + opt_partition:partition + opt_distribution:distribution + opt_rollup:index + opt_properties:tblProperties + opt_ext_properties:extProperties + KW_AS query_stmt:query_def ``` 说明: - 用户需要拥有来源表的`SELECT`权限和目标库的`CREATE`权限 - 创建表成功后,会进行数据导入,如果导入失败,将会删除表 +- 可以自行指定 key type,默认为`Duplicate Key` ### Example 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 22e78471b0..c9e19b0c60 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 @@ -323,6 +323,21 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService { showResultSet.getResultRows().get(0).get(1)); } + @Test + public void testUseKeyType() throws Exception { + String createSql = "create table `test`.`test_use_key_type` UNIQUE KEY(`userId`) PROPERTIES (\"replication_num\" = \"1\")" + + " as select * from `test`.`varchar_table`"; + createTableAsSelect(createSql); + ShowResultSet showResultSet = showCreateTableByName("test_use_key_type"); + Assertions.assertEquals( + "CREATE TABLE `test_use_key_type` (\n" + " `userId` varchar(255) NOT NULL,\n" + + " `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" + "\"in_memory\" = \"false\",\n" + + "\"storage_format\" = \"V2\",\n" + "\"disable_auto_compaction\" = \"false\"\n" + ");", + showResultSet.getResultRows().get(0).get(1)); + } + @Test public void testQuerySchema() throws Exception { connectContext.setDatabase("default_cluster:test"); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org