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

commit a2552c825440fd89ce7d7e9008ce7969727a514d
Author: htyoung <hty551...@hotmail.com>
AuthorDate: Fri Aug 23 21:06:17 2024 +0800

    [fix](fe) LIST partition table support modify default bucket num (#39696)
    
    Issue Number: close #39684
    
    Co-authored-by: tongyang.han <tongyang....@jiduauto.com>
---
 .../main/java/org/apache/doris/catalog/Env.java    |  5 +-
 .../data/alter_p1/test_alter_modify_bucket.out     |  6 ++
 .../alter_p1/test_alter_modify_bucket.groovy       | 86 ++++++++++++++++++++++
 3 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 38483e03ab5..3003e832d96 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -4737,7 +4737,7 @@ public class Env {
         GroupId groupId = null;
         if (!Strings.isNullOrEmpty(assignedGroup)) {
             String fullAssignedGroupName = 
GroupId.getFullGroupName(db.getId(), assignedGroup);
-            //When the new name is the same as the old name, we return it to 
prevent npe
+            // When the new name is the same as the old name, we return it to 
prevent npe
             if (!Strings.isNullOrEmpty(oldGroup)) {
                 String oldFullGroupName = GroupId.getFullGroupName(db.getId(), 
oldGroup);
                 if (oldFullGroupName.equals(fullAssignedGroupName)) {
@@ -5354,7 +5354,8 @@ public class Env {
                 throw new DdlException("Cannot change default bucket number of 
colocate table.");
             }
 
-            if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) 
{
+            if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE
+                    && olapTable.getPartitionInfo().getType() != 
PartitionType.LIST) {
                 throw new DdlException("Only support change partitioned 
table's distribution.");
             }
 
diff --git a/regression-test/data/alter_p1/test_alter_modify_bucket.out 
b/regression-test/data/alter_p1/test_alter_modify_bucket.out
new file mode 100644
index 00000000000..bc2edf63bc6
--- /dev/null
+++ b/regression-test/data/alter_p1/test_alter_modify_bucket.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1      1       2024-08-20      21      21:00:00        2024-08-20      
1724158800000
+2      2       2024-08-20      22      22:00:00        2024-08-20      
1724162400000
+3      3       2024-08-20      23      23:00:00        2024-08-20      
1724166000000
+
diff --git a/regression-test/suites/alter_p1/test_alter_modify_bucket.groovy 
b/regression-test/suites/alter_p1/test_alter_modify_bucket.groovy
new file mode 100644
index 00000000000..1c8c8b62aff
--- /dev/null
+++ b/regression-test/suites/alter_p1/test_alter_modify_bucket.groovy
@@ -0,0 +1,86 @@
+// 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_alter_modify_bucket') {
+    def tbl = 'test_alter_modify_bucket_tbl'
+    sql "DROP TABLE IF EXISTS ${tbl} FORCE"
+    sql """
+        CREATE TABLE ${tbl} (
+            `id1` VARCHAR(255) NULL COMMENT 'id1',
+            `id2` VARCHAR(255) NULL COMMENT 'id2',
+            `dt` VARCHAR(255) NOT NULL COMMENT '日期分区',
+            `hr` VARCHAR(255) NOT NULL COMMENT '小时分区',
+            `event_time` VARCHAR(255) NULL COMMENT '事件时间',
+            `event_date` VARCHAR(255) NULL COMMENT '事件日期',
+            `event_ts` VARCHAR(256) NULL COMMENT '事件发生时间戳(毫秒)'
+        ) ENGINE=OLAP
+        UNIQUE KEY(`id1`,`id2`,`dt`,`hr`)
+        COMMENT 'xxx' 
+        PARTITION BY LIST(`dt`, `hr`) (
+            PARTITION p2024082021 VALUES IN (("2024-08-20", "21"))
+        )
+        DISTRIBUTED BY HASH(`id1`,`id2`) BUCKETS 1
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    // check existed partition buckets
+    List<List<Object>> res = sql """
+        SHOW PARTITIONS FROM ${tbl}
+    """
+    assertEquals(res[0][8],"1")
+
+    // add new partition and insert values
+    sql """
+        ALTER TABLE ${tbl} ADD PARTITION IF NOT EXISTS p2024082022 VALUES IN 
(("2024-08-20", "22"))
+    """
+    sql """
+        INSERT INTO ${tbl} 
VALUES("1","1","2024-08-20","21","21:00:00","2024-08-20","1724158800000")
+    """
+    sql """
+        INSERT INTO ${tbl} 
VALUES("2","2","2024-08-20","22","22:00:00","2024-08-20","1724162400000")
+    """
+
+    // modify table default buckets
+    sql """
+        ALTER TABLE ${tbl} MODIFY DISTRIBUTION DISTRIBUTED BY 
HASH(`id1`,`id2`) BUCKETS 2
+    """
+
+    // add new partition after modify tablet default buckets and insert values
+    sql """
+        ALTER TABLE ${tbl} ADD PARTITION IF NOT EXISTS p2024082023 VALUES IN 
(("2024-08-20", "23"))
+    """
+    sql """
+        INSERT INTO ${tbl} 
VALUES("3","3","2024-08-20","23","23:00:00","2024-08-20","1724166000000")
+    """
+
+    // check all insert values
+    qt_select """
+        SELECT * FROM ${tbl} ORDER BY id1,id2
+    """
+
+    // check all partition buckets
+    List<List<Object>> res1 = sql """
+        SHOW PARTITIONS FROM ${tbl} ORDER BY `PartitionName`
+    """
+    assertEquals(res1[0][8],"1")
+    assertEquals(res1[1][8],"1")
+    assertEquals(res1[2][8],"2")
+
+    sql "DROP TABLE IF EXISTS ${tbl} FORCE"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to