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 6bb859674aa [fix](schema-change) Rebuild distribution info according
to original order (#54024) (#54072) (#54109)
6bb859674aa is described below
commit 6bb859674aa66690a1f07caa4d75908e543470b8
Author: Siyang Tang <[email protected]>
AuthorDate: Wed Jul 30 23:21:38 2025 +0800
[fix](schema-change) Rebuild distribution info according to original order
(#54024) (#54072) (#54109)
### What problem does this PR solve?
cherry-pick: #54024 #54072
---
.../java/org/apache/doris/catalog/OlapTable.java | 12 ++--
.../test_random_ordered_bucket_columns.out | Bin 0 -> 159 bytes
.../test_random_ordered_bucket_columns.groovy | 61 +++++++++++++++++++++
3 files changed, 65 insertions(+), 8 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
index 3d4b5cc1d6f..9d48e34afaf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
@@ -492,17 +492,13 @@ public class OlapTable extends Table implements
MTMVRelatedTableIf, GsonPostProc
return;
}
HashDistributionInfo distributionInfo = (HashDistributionInfo)
defaultDistributionInfo;
- Set<String> originalColumnsNames =
- distributionInfo.getDistributionColumns()
- .stream()
- .map(Column::getName)
- .collect(Collectors.toSet());
-
- List<Column> newDistributionColumns = getBaseSchema()
+ List<Column> newDistributionColumns =
distributionInfo.getDistributionColumns()
.stream()
- .filter(column ->
originalColumnsNames.contains(column.getName()))
+ .map(Column::getName)
+ .map(this::getBaseColumn)
.map(Column::new)
.collect(Collectors.toList());
+
distributionInfo.setDistributionColumns(newDistributionColumns);
getPartitions()
diff --git
a/regression-test/data/schema_change_p0/test_random_ordered_bucket_columns.out
b/regression-test/data/schema_change_p0/test_random_ordered_bucket_columns.out
new file mode 100644
index 00000000000..e59e71b86c7
Binary files /dev/null and
b/regression-test/data/schema_change_p0/test_random_ordered_bucket_columns.out
differ
diff --git
a/regression-test/suites/schema_change_p0/test_random_ordered_bucket_columns.groovy
b/regression-test/suites/schema_change_p0/test_random_ordered_bucket_columns.groovy
new file mode 100644
index 00000000000..a0856595882
--- /dev/null
+++
b/regression-test/suites/schema_change_p0/test_random_ordered_bucket_columns.groovy
@@ -0,0 +1,61 @@
+// 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_random_ordered_bucket_columns') {
+ def tblName = "test_random_ordered_bucket_columns"
+ sql """ DROP TABLE IF EXISTS ${tblName}; """
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tblName}
+ (
+ k1 DATE,
+ k2 INT DEFAULT '10',
+ k3 bigint,
+ k4 VARCHAR(32) DEFAULT '',
+ v1 BIGINT DEFAULT '0'
+ )
+ UNIQUE KEY(k1, k2, k3, k4)
+ DISTRIBUTED BY HASH(k3, k4, k1, k2) BUCKETS 5
+ PROPERTIES("replication_num" = "1", "light_schema_change" = "true");
+ """
+
+ // show create table differs in local and cloud mode, this behavior is
verified
+ // qt_sql """ SHOW CREATE TABLE ${tblName} """
+
+ sql """ INSERT INTO ${tblName} VALUES("2025-07-29", 0, 1, "2", 3) """
+
+ sql """ INSERT INTO ${tblName} VALUES("2025-07-29", 0, 1, "2", 3) """
+
+ sql """ SYNC """
+
+ qt_sql """ SELECT * FROM ${tblName} """
+
+ sql """ ALTER TABLE ${tblName} ADD COLUMN v2 BIGINT DEFAULT '1' """
+
+
+ // sql """ SYNC """
+
+ // show create table differs in local and cloud mode, this behavior is
verified
+ // qt_sql """ SHOW CREATE TABLE ${tblName} """
+
+ 30.times { index ->
+ sql """ INSERT INTO ${tblName} VALUES("2025-07-29", 0, 1, "2", 3, 0)
"""
+ }
+
+ sql """ SYNC """
+
+ qt_sql """ SELECT * FROM ${tblName} """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]