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 40383826f4..1797766546 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 @@ -516,7 +516,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 6456e31a5d..2a7aa291d0 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 0000000000..ccb7fe6195 --- /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_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); + +-- !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_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); + 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 0000000000..704772a0a9 --- /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