This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new fb2ccf0ebd8 [fix][cherrypick](fe) LIST partition table support modify
default bucket num (#40032)
fb2ccf0ebd8 is described below
commit fb2ccf0ebd83c5dd4c7ef6c5dee49be2c1b4a145
Author: htyoung <[email protected]>
AuthorDate: Fri Aug 30 14:39:04 2024 +0800
[fix][cherrypick](fe) LIST partition table support modify default bucket
num (#40032)
cherry pick from #39696
---
.../main/java/org/apache/doris/catalog/Env.java | 3 +-
.../data/alter_p1/test_alter_modify_bucket.out | 6 ++
.../alter_p1/test_alter_modify_bucket.groovy | 86 ++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)
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 4bb4fd86557..91154b8d76c 100755
--- 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
@@ -4772,7 +4772,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: [email protected]
For additional commands, e-mail: [email protected]