This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new da944cf2e95 [fix](create table) fix nereids create table no check
buckets=0 (#38971)
da944cf2e95 is described below
commit da944cf2e9510073e2a2c168bb3668e75128b272
Author: yujun <[email protected]>
AuthorDate: Wed Aug 7 09:46:21 2024 +0800
[fix](create table) fix nereids create table no check buckets=0 (#38971)
Fix: nereids create table no check buckets=0
---
.../commands/info/DistributionDescriptor.java | 3 ++
.../suites/table_p0/test_table_with_buckets.groovy | 53 ++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DistributionDescriptor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DistributionDescriptor.java
index 86b158a9e06..056bfd20897 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DistributionDescriptor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DistributionDescriptor.java
@@ -72,6 +72,9 @@ public class DistributionDescriptor {
* analyze distribution descriptor
*/
public void validate(Map<String, ColumnDefinition> columnMap, KeysType
keysType) {
+ if (bucketNum <= 0) {
+ throw new AnalysisException("Buckets number of distribution should
be greater than zero.");
+ }
if (isHash) {
Set<String> colSet = Sets.newHashSet(cols);
if (colSet.size() != cols.size()) {
diff --git a/regression-test/suites/table_p0/test_table_with_buckets.groovy
b/regression-test/suites/table_p0/test_table_with_buckets.groovy
new file mode 100644
index 00000000000..efec750839d
--- /dev/null
+++ b/regression-test/suites/table_p0/test_table_with_buckets.groovy
@@ -0,0 +1,53 @@
+// 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_table_with_buckets') {
+ def tbl1 = 'test_table_with_buckets_tbl1'
+ def tbl2 = 'test_table_with_buckets_tbl2'
+ sql "drop table if exists `${tbl1}`"
+ sql "drop table if exists `${tbl2}`"
+ try {
+ test {
+ sql "create table ${tbl1}(k int) distributed by hash(k) buckets 0
properties('replication_num' = '1')"
+ exception 'Buckets number of distribution should be greater than
zero.'
+ }
+
+ test {
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tbl2} ( k1 date NOT NULL, k2
varchar(20) NOT NULL, k3 int sum NOT NULL )
+ AGGREGATE KEY(k1,k2)
+ PARTITION BY RANGE(k1) ( )
+ DISTRIBUTED BY HASH(k1) BUCKETS 3
+ PROPERTIES (
+ "dynamic_partition.enable"="true",
+ "dynamic_partition.end"="3",
+ "dynamic_partition.buckets"="0",
+ "dynamic_partition.start"="-3",
+ "dynamic_partition.prefix"="p",
+ "dynamic_partition.time_unit"="DAY",
+ "dynamic_partition.create_history_partition"="true",
+ "dynamic_partition.replication_allocation" =
"tag.location.default: 1"
+ )
+ """
+
+ exception 'Dynamic partition buckets must greater than 0'
+ }
+ } finally {
+ sql "drop table if exists `${tbl1}`"
+ sql "drop table if exists `${tbl2}`"
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]