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

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new cbf7e54b9c5 branch-4.0: [fix](Rollup) When creating a table with 
rollup and setting a sequence column, we should correctly configure the 
uniqueId of the sequence column #56143 (#57389)
cbf7e54b9c5 is described below

commit cbf7e54b9c578ff4b059806743e93e34fe5a01b2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Oct 28 11:38:19 2025 +0800

    branch-4.0: [fix](Rollup) When creating a table with rollup and setting a 
sequence column, we should correctly configure the uniqueId of the sequence 
column #56143 (#57389)
    
    Cherry-picked from #56143
    
    Co-authored-by: shee <[email protected]>
    Co-authored-by: garenshi <[email protected]>
---
 .../java/org/apache/doris/catalog/OlapTable.java   | 22 ++++++++----
 .../rollup_p0/test_create_table_with_rollup.out    |  4 +++
 .../rollup_p0/test_create_table_with_rollup.groovy | 42 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 7 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 a0421b3e445..a465f2f6c9b 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
@@ -1611,6 +1611,20 @@ public class OlapTable extends Table implements 
MTMVRelatedTableIf, GsonPostProc
         this.hasSequenceCol = true;
         this.sequenceType = type;
 
+        Column sequenceCol = buildSequenceCol(type, refColumn);
+        // add sequence column at last
+        fullSchema.add(sequenceCol);
+        nameToColumn.put(Column.SEQUENCE_COL, sequenceCol);
+        for (MaterializedIndexMeta indexMeta : indexIdToMeta.values()) {
+            List<Column> schema = indexMeta.getSchema();
+            if (indexMeta.getIndexId() != baseIndexId) {
+                sequenceCol = buildSequenceCol(type, refColumn);
+            }
+            schema.add(sequenceCol);
+        }
+    }
+
+    private Column buildSequenceCol(Type type, Column refColumn) {
         Column sequenceCol;
         if (getEnableUniqueKeyMergeOnWrite()) {
             // sequence column is value column with NONE aggregate type for
@@ -1624,13 +1638,7 @@ public class OlapTable extends Table implements 
MTMVRelatedTableIf, GsonPostProc
         if (refColumn != null) {
             sequenceCol.setDefaultValueInfo(refColumn);
         }
-        // add sequence column at last
-        fullSchema.add(sequenceCol);
-        nameToColumn.put(Column.SEQUENCE_COL, sequenceCol);
-        for (MaterializedIndexMeta indexMeta : indexIdToMeta.values()) {
-            List<Column> schema = indexMeta.getSchema();
-            schema.add(sequenceCol);
-        }
+        return sequenceCol;
     }
 
     public Column getSequenceCol() {
diff --git a/regression-test/data/rollup_p0/test_create_table_with_rollup.out 
b/regression-test/data/rollup_p0/test_create_table_with_rollup.out
new file mode 100644
index 00000000000..dde5b079b74
--- /dev/null
+++ b/regression-test/data/rollup_p0/test_create_table_with_rollup.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      2025-01-01T00:00        1
+
diff --git 
a/regression-test/suites/rollup_p0/test_create_table_with_rollup.groovy 
b/regression-test/suites/rollup_p0/test_create_table_with_rollup.groovy
new file mode 100644
index 00000000000..220c02a1b03
--- /dev/null
+++ b/regression-test/suites/rollup_p0/test_create_table_with_rollup.groovy
@@ -0,0 +1,42 @@
+// 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_create_table_with_rollup") {
+
+    def tbName = "test_create_table_with_rollup"
+
+    sql "DROP TABLE IF EXISTS ${tbName}"
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tbName}( 
+                user_id VARCHAR(32) NOT NULL,
+                event_time DATETIME NOT NULL,
+                val1 BIGINT NOT NULL
+            ) ENGINE=OLAP
+            UNIQUE KEY(user_id, event_time)
+            DISTRIBUTED BY HASH(user_id) BUCKETS 1
+            ROLLUP(r1(event_time, user_id))
+            PROPERTIES (
+               "replication_allocation" = "tag.location.default: 1",
+               "function_column.sequence_col" = "event_time"
+            );
+        """
+
+    sql "insert into ${tbName} values(1,'2025-01-01 00:00:00',1)"
+
+    qt_sql "select * from ${tbName}"
+
+    sql "DROP TABLE ${tbName} FORCE;"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to