Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #56143

…e 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:
apache/doris-website#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 <garenshi@tencnet.com>
@github-actions github-actions bot requested a review from morrySnow as a code owner October 27, 2025 17:22
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Oct 27, 2025
@hello-stephen
Copy link
Contributor

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 33260 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 7ffcd6763ef51813f3dfabe2210cd7199ea724f4, data reload: false

------ Round 1 ----------------------------------
q1	17641	5524	5521	5521
q2	2045	403	294	294
q3	12089	1252	761	761
q4	10247	904	463	463
q5	8414	2404	2210	2210
q6	184	171	132	132
q7	910	749	624	624
q8	9334	1480	1281	1281
q9	5305	4961	4951	4951
q10	6782	2294	1859	1859
q11	487	285	273	273
q12	340	362	218	218
q13	17798	3644	3007	3007
q14	227	232	206	206
q15	523	468	468	468
q16	425	438	380	380
q17	613	876	383	383
q18	7153	6503	6569	6503
q19	1819	990	549	549
q20	322	345	203	203
q21	3034	2231	2028	2028
q22	1046	1016	946	946
Total cold run time: 106738 ms
Total hot run time: 33260 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5617	5509	5521	5509
q2	238	333	236	236
q3	2265	2675	2335	2335
q4	1378	1766	1366	1366
q5	4438	5093	5050	5050
q6	174	170	136	136
q7	2138	1965	1873	1873
q8	2694	2864	2753	2753
q9	7321	7342	7218	7218
q10	3074	3265	2751	2751
q11	579	519	515	515
q12	684	791	604	604
q13	3472	3767	3194	3194
q14	285	303	267	267
q15	516	458	489	458
q16	438	495	456	456
q17	1256	1737	1274	1274
q18	7768	7494	7512	7494
q19	826	1228	1092	1092
q20	2039	2089	1943	1943
q21	5473	5027	4615	4615
q22	1103	1068	1031	1031
Total cold run time: 53776 ms
Total hot run time: 52170 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 192784 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 7ffcd6763ef51813f3dfabe2210cd7199ea724f4, data reload: false

query1	964	411	417	411
query2	6254	1977	1907	1907
query3	8689	208	204	204
query4	33719	24299	23456	23456
query5	3825	614	466	466
query6	290	189	179	179
query7	4200	494	313	313
query8	299	246	240	240
query9	9301	2609	2617	2609
query10	486	325	269	269
query11	17894	15429	15313	15313
query12	156	116	119	116
query13	1567	546	438	438
query14	9569	7236	6722	6722
query15	253	198	189	189
query16	8139	684	507	507
query17	1543	769	626	626
query18	2151	437	322	322
query19	234	202	168	168
query20	134	126	125	125
query21	218	132	123	123
query22	4517	4556	4408	4408
query23	35056	34024	33950	33950
query24	7455	2761	2763	2761
query25	551	512	444	444
query26	1181	294	177	177
query27	2180	499	372	372
query28	5020	2240	2224	2224
query29	801	629	463	463
query30	239	196	160	160
query31	1004	957	840	840
query32	98	59	64	59
query33	530	375	301	301
query34	752	859	544	544
query35	816	830	750	750
query36	1033	1059	969	969
query37	112	95	73	73
query38	4085	4090	3946	3946
query39	1514	1524	1480	1480
query40	215	116	104	104
query41	50	48	47	47
query42	121	108	103	103
query43	521	553	511	511
query44	1390	885	839	839
query45	186	185	174	174
query46	901	1062	687	687
query47	1995	1992	2002	1992
query48	426	439	352	352
query49	773	500	405	405
query50	697	717	442	442
query51	7397	7330	7290	7290
query52	107	102	94	94
query53	242	272	212	212
query54	566	568	490	490
query55	84	78	82	78
query56	295	291	258	258
query57	1306	1273	1240	1240
query58	247	229	222	222
query59	3116	3328	3151	3151
query60	310	303	278	278
query61	112	112	114	112
query62	826	755	710	710
query63	248	203	202	202
query64	4635	1001	647	647
query65	3422	3279	3314	3279
query66	1111	444	333	333
query67	16453	15882	15738	15738
query68	7776	831	555	555
query69	482	305	276	276
query70	1148	1140	1142	1140
query71	386	298	274	274
query72	5643	3712	3871	3712
query73	640	758	357	357
query74	10639	9165	8898	8898
query75	3279	3174	2666	2666
query76	3147	1175	794	794
query77	701	365	289	289
query78	10403	10499	9682	9682
query79	3589	917	585	585
query80	696	523	442	442
query81	492	254	224	224
query82	558	120	89	89
query83	188	163	151	151
query84	298	95	83	83
query85	783	377	310	310
query86	355	327	307	307
query87	4303	4388	4221	4221
query88	4459	2409	2394	2394
query89	408	328	300	300
query90	1838	194	192	192
query91	140	140	108	108
query92	63	57	53	53
query93	1642	908	552	552
query94	685	409	317	317
query95	347	282	272	272
query96	497	612	286	286
query97	3242	3260	3167	3167
query98	222	210	209	209
query99	1577	1455	1265	1265
Total cold run time: 295207 ms
Total hot run time: 192784 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 28.89 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 7ffcd6763ef51813f3dfabe2210cd7199ea724f4, data reload: false

query1	0.03	0.03	0.03
query2	0.07	0.03	0.03
query3	0.23	0.07	0.06
query4	1.62	0.12	0.11
query5	0.54	0.51	0.53
query6	1.13	0.73	0.72
query7	0.03	0.01	0.01
query8	0.04	0.03	0.03
query9	0.57	0.51	0.50
query10	0.56	0.55	0.55
query11	0.14	0.10	0.10
query12	0.14	0.11	0.10
query13	0.63	0.61	0.61
query14	0.78	0.79	0.82
query15	0.85	0.84	0.85
query16	0.39	0.40	0.37
query17	1.01	1.06	1.10
query18	0.24	0.23	0.22
query19	2.02	1.87	1.86
query20	0.01	0.02	0.01
query21	15.37	0.99	0.57
query22	0.74	0.80	0.59
query23	15.13	1.46	0.58
query24	2.69	0.90	0.98
query25	0.26	0.06	0.05
query26	0.30	0.15	0.13
query27	0.04	0.04	0.04
query28	13.33	1.06	0.44
query29	12.56	3.91	3.28
query30	0.25	0.09	0.06
query31	2.84	0.63	0.39
query32	3.22	0.54	0.46
query33	3.00	3.02	3.09
query34	16.60	5.24	4.52
query35	4.62	4.57	4.54
query36	0.66	0.50	0.50
query37	0.09	0.06	0.06
query38	0.05	0.03	0.04
query39	0.04	0.03	0.02
query40	0.16	0.12	0.13
query41	0.08	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.04	0.03
Total cold run time: 103.14 s
Total hot run time: 28.89 s

@morrySnow morrySnow merged commit d4b6f36 into branch-3.1 Oct 30, 2025
23 checks passed
@morrySnow morrySnow deleted the auto-pick-56143-branch-3.1 branch October 30, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants