This is an automated email from the ASF dual-hosted git repository.
morningman 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 6c10c47f791 [fix](fe) LIST partition table support modify default
bucket num (#39688)
6c10c47f791 is described below
commit 6c10c47f791ca089776de4a9dd969b4cb5300575
Author: htyoung <[email protected]>
AuthorDate: Fri Aug 23 11:52:16 2024 +0800
[fix](fe) LIST partition table support modify default bucket num (#39688)
## Proposed changes
bp #39696
Issue Number: close #39684
```sql
CREATE TABLE `test1` (
`id1` VARCHAR(255) NULL COMMENT 'id1',
`id2` VARCHAR(255) NULL COMMENT 'id2',
`event_time` VARCHAR(255) NULL COMMENT '事件时间',
`event_date` VARCHAR(255) NULL COMMENT '事件日期',
`event_ts` VARCHAR(256) NULL COMMENT '事件发生时间戳(毫秒)',
`dt` VARCHAR(255) NOT NULL COMMENT '日期分区',
`hr` VARCHAR(255) NOT NULL COMMENT '小时分区'
) ENGINE = OLAP DUPLICATE KEY(`id1`) COMMENT 'xxx' PARTITION BY
LIST(`dt`, `hr`) (
PARTITION p2024082021 VALUES IN (("2024-08-20", "21"))
) DISTRIBUTED BY HASH(`dt`, `hr`) BUCKETS 2 PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V1",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728"
);
```
1. 修改前表已有分区的bucket num为2

2. 修改List分区表bucket num(从2 -> 4)

3. 修改List分区后,添加的新分区bucket num为4

Co-authored-by: tongyang.han <[email protected]>
---
.../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 d6af35c5bf1..0811d52a9cb 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
@@ -4577,7 +4577,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)) {
@@ -5180,7 +5180,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]