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

yiguolei 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 c9e1435c0ac [fix](schema-change) Rebuild distribution info according 
to original order (#54024) (#54072) (#54111)
c9e1435c0ac is described below

commit c9e1435c0acbb6cb1c38eb6d365c0b356a7d07e2
Author: Siyang Tang <[email protected]>
AuthorDate: Fri Aug 1 11:48:19 2025 +0800

    [fix](schema-change) Rebuild distribution info according to original order 
(#54024) (#54072) (#54111)
    
    ### What problem does this PR solve?
    
    Cherry-pick: #54024 #54072
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [x] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [x] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [x] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 .../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 5c6b5a3d2d8..b771a8e9ef9 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
@@ -453,17 +453,13 @@ public class OlapTable extends Table implements 
MTMVRelatedTableIf {
             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]

Reply via email to