This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 1823be98624 [fix](Rollup) When creating a table with rollup and
setting a sequence column, we should correctly configure the uniqueId of the
sequence column (#56143)
1823be98624 is described below
commit 1823be9862444d35c5d7619f2dff90c15568034c
Author: shee <[email protected]>
AuthorDate: Tue Oct 28 01:21:27 2025 +0800
[fix](Rollup) When creating a table with rollup and setting a sequence
column, we should correctly configure the uniqueId of the sequence column
(#56143)
Doris version master
```sql
CREATE TABLE IF NOT EXISTS users(
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 ( rlp_spacetime_collision(event_time, user_id) )
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"function_column.sequence_col" = "event_time"
);
mysql> insert into users values(1,'2025-01-01 00:00:00',1);Query OK, 1 row
affected (0.18 sec)
mysql> select * from users1;
ERROR 1105 (HY000): errCode = 2, detailMessage =
(9.134.213.24)[E-207]slot(id: 3, name: __DORIS_DELETE_SIGN__)'s nullable does
not match column(tablet id: -1, index: 5, name: __DORIS_SEQUENCE_COL__)
```
The reasons are as follows.
all `MaterializedIndexMeta` shared one `sequenceCol`
```java
public void setSequenceInfo(Type type, Column refColumn) {
this.hasSequenceCol = true;
this.sequenceType = type;
Column sequenceCol;
if (getEnableUniqueKeyMergeOnWrite()) {
// sequence column is value column with NONE aggregate type for
// unique key table with merge on write
sequenceCol = ColumnDef.newSequenceColumnDef(type,
AggregateType.NONE).toColumn();
} else {
// sequence column is value column with REPLACE aggregate type
for
// unique key table
sequenceCol = ColumnDef.newSequenceColumnDef(type,
AggregateType.REPLACE).toColumn();
}
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);
}
}
```
when init column `uniqueId`, base index sequence column unique id
override roullup index sequence column `uniqueId `
```java
public void initSchemaColumnUniqueId() {
maxColUniqueId = Column.COLUMN_UNIQUE_ID_INIT_VALUE;
this.schema.forEach(column -> {
column.setUniqueId(incAndGetMaxColUniqueId());
if (LOG.isDebugEnabled()) {
LOG.debug("indexId: {}, column:{}, uniqueId:{}",
indexId, column, column.getUniqueId());
}
});
}
```
then BE will make an incorrect judgment.
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] 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:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] 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 -->
---------
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 5ca421ce007..e67862a7eb6 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]