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

dataroaring pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 80b63452702 [fix](create table) fix nereids create table no check 
buckets=0 #38971 (#38999)
80b63452702 is described below

commit 80b63452702eea59a1c0625258afa650816c5cbf
Author: yujun <yu.jun.re...@gmail.com>
AuthorDate: Fri Aug 9 21:34:35 2024 +0800

    [fix](create table) fix nereids create table no check buckets=0 #38971 
(#38999)
    
    cherry pick from #38971
---
 .../commands/info/DistributionDescriptor.java      |  3 ++
 .../suites/table_p0/test_table_with_buckets.groovy | 54 ++++++++++++++++++++++
 2 files changed, 57 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..45c73bf7e7f
--- /dev/null
+++ b/regression-test/suites/table_p0/test_table_with_buckets.groovy
@@ -0,0 +1,54 @@
+// 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 '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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to