This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 7e2bcb57845 [Feat](planner)create table stmt offer default 
distribution attribute :random distribution and auto bucket (#35189)
7e2bcb57845 is described below

commit 7e2bcb57845fa0cb8a3477273be26ddb3391be20
Author: feiniaofeiafei <[email protected]>
AuthorDate: Wed May 22 15:17:46 2024 +0800

    [Feat](planner)create table stmt offer default distribution attribute 
:random distribution and auto bucket (#35189)
    
    Co-authored-by: feiniaofeiafei <[email protected]>
---
 .../org/apache/doris/analysis/CreateTableStmt.java |  2 +-
 .../trees/plans/commands/info/CreateTableInfo.java |  2 +-
 .../test_create_table_without_distribution.out     | 19 ++++++++++
 .../test_create_table_without_distribution.groovy  | 43 ++++++++++++++++++++++
 4 files changed, 64 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
index 5147ccc67e0..898e2744ee6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
@@ -511,7 +511,7 @@ public class CreateTableStmt extends DdlStmt {
 
             // analyze distribution
             if (distributionDesc == null) {
-                throw new AnalysisException("Create olap table should contain 
distribution desc");
+                distributionDesc = new 
RandomDistributionDesc(FeConstants.default_bucket_num, true);
             }
             distributionDesc.analyze(columnSet, columnDefs, keysDesc);
             if (distributionDesc.type == 
DistributionInfo.DistributionInfoType.RANDOM) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
index 4625be16658..c2ed6f664c6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
@@ -210,7 +210,7 @@ public class CreateTableInfo {
 
         if (engineName.equalsIgnoreCase("olap")) {
             if (distribution == null) {
-                throw new AnalysisException("Create olap table should contain 
distribution desc");
+                distribution = new DistributionDescriptor(false, true, 
FeConstants.default_bucket_num, null);
             }
             properties = maybeRewriteByAutoBucket(distribution, properties);
         }
diff --git 
a/regression-test/data/ddl_p0/test_create_table_without_distribution.out 
b/regression-test/data/ddl_p0/test_create_table_without_distribution.out
new file mode 100644
index 00000000000..ccb7fe6195f
--- /dev/null
+++ b/regression-test/data/ddl_p0/test_create_table_without_distribution.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_insert --
+1
+
+-- !test_select --
+1      2
+
+-- !test_show --
+test_create_table_without_distribution CREATE TABLE 
`test_create_table_without_distribution` (\n  `a` INT NULL,\n  `b` INT NULL\n) 
ENGINE=OLAP\nDUPLICATE KEY(`a`, `b`)\nCOMMENT 'OLAP'\nDISTRIBUTED BY RANDOM 
BUCKETS AUTO\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 
1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = 
"false",\n"storage_medium" = "hdd",\n"storage_format" = 
"V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = 
"true",\n"disable_auto [...]
+
+-- !test_insert_old_planner --
+1
+
+-- !test_select_old_planner --
+1      2
+
+-- !test_show_old_planner --
+test_create_table_without_distribution CREATE TABLE 
`test_create_table_without_distribution` (\n  `a` INT NULL,\n  `b` INT NULL\n) 
ENGINE=OLAP\nDUPLICATE KEY(`a`, `b`)\nCOMMENT 'OLAP'\nDISTRIBUTED BY RANDOM 
BUCKETS AUTO\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 
1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = 
"false",\n"storage_medium" = "hdd",\n"storage_format" = 
"V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = 
"true",\n"disable_auto [...]
+
diff --git 
a/regression-test/suites/ddl_p0/test_create_table_without_distribution.groovy 
b/regression-test/suites/ddl_p0/test_create_table_without_distribution.groovy
new file mode 100644
index 00000000000..704772a0a95
--- /dev/null
+++ 
b/regression-test/suites/ddl_p0/test_create_table_without_distribution.groovy
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_create_table_without_distribution") {
+    sql "SET enable_nereids_planner=true;"
+    sql "SET enable_fallback_to_original_planner=false;"
+    multi_sql """
+    drop table if exists test_create_table_without_distribution;
+    create table test_create_table_without_distribution(a int, b int) 
properties ("replication_num"="1")   
+    """
+    qt_test_insert """
+    insert into test_create_table_without_distribution values(1,2);
+    """
+    qt_test_select "select * from test_create_table_without_distribution;"
+    qt_test_show " show create table test_create_table_without_distribution;"
+
+    sql "SET enable_nereids_planner=false;"
+    multi_sql """
+    drop table if exists test_create_table_without_distribution;
+    create table test_create_table_without_distribution(a int, b int) 
properties ("replication_num"="1")   
+    """
+    qt_test_insert_old_planner """
+    insert into test_create_table_without_distribution values(1,2);
+    """
+    qt_test_select_old_planner "select * from 
test_create_table_without_distribution;"
+    qt_test_show_old_planner " show create table 
test_create_table_without_distribution;"
+
+
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to