Skip to content

[feature](routineload) Add routine load target-table alter support#64878

Open
0AyanamiRei wants to merge 13 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch
Open

[feature](routineload) Add routine load target-table alter support#64878
0AyanamiRei wants to merge 13 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch

Conversation

@0AyanamiRei

@0AyanamiRei 0AyanamiRei commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:

Routine Load target-table alteration was initially limited to the target-only syntax ALTER ROUTINE LOAD FOR [db.]job ON table. It could not alter supported job or data-source properties in the same statement.

This PR replaces that syntax with the explicit, composable form:

ALTER ROUTINE LOAD FOR [<db>.]<job_name>
SET TARGET TABLE = "<table_name>"
[<job_properties>]
FROM [<data_source>]
[<data_source_properties>]

The implementation has the following behavior and constraints:

  • SET TARGET TABLE can be combined with supported job properties and Kafka/Kinesis data-source properties.
  • Target switching remains mutually exclusive with load clauses such as COLUMNS, WHERE, and PARTITION.
  • The job must be paused and single-table. The target must be a non-temporary OLAP table in the job database, pass LOAD privilege checks, and be compatible with the existing load description, distribution mode, and partial-update settings.
  • An explicit FROM type must match the existing job type; Kafka and Kinesis jobs cannot be converted into each other.
  • Existing Doris mutable-property allowlists are preserved. Unknown/create-only properties are rejected, including Kafka multi-table routing properties during ALTER. Doris retains its existing support for altering kafka_topic, unlike StarRocks.
  • Target-table, job-property, and data-source changes are applied and persisted together. Kafka source changes are staged or prevalidated to avoid partial in-memory mutation, and replay does not perform offset lookups or Cloud MetaService RPCs.
  • Kafka/Kinesis default offsets or positions are changed only when explicitly supplied. Altering a broker, stream, or custom property no longer synthesizes and overwrites an unspecified default position.
  • Routine Load progress is preserved for target-only/custom-property changes; topic or stream changes retain the existing Doris progress-reset behavior.

Release note

ALTER ROUTINE LOAD now uses SET TARGET TABLE = "table" to switch the target table and supports combining the switch with supported PROPERTIES and FROM data-source properties in one statement.

Check List (For Author)

  • Test

    • 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
  • Behavior changed:

    • No.
    • Yes. The target-table syntax changes from ON table to SET TARGET TABLE = "table", and supported job/source properties can now be altered in the same statement.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: None
Related PR: None
Problem Summary: Allow paused single-table Routine Load jobs to switch their target table with ALTER ROUTINE LOAD FOR [db.]job ON <table>, while preserving existing progress and replaying the new table binding from edit log.

### Release note

Support ALTER ROUTINE LOAD ... ON <table> to switch the target table for paused single-table routine load jobs.

### Check List (For Author)

- Test: FE unit test
  - "/data/data3/huangruixin/include/src-master/apache-maven-3.9.9/bin/mvn -pl fe-core -am -DskipITs -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.persist.AlterRoutineLoadOperationLogTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest test"
  - Kinesis unit tests skipped per user request
- Behavior changed: Yes (new ALTER ROUTINE LOAD target-table switch behavior)
- Does this need documentation: Yes (documented in /data/data3/huangruixin/docs/routine-load-alter-table-design.html)
@hello-stephen

Copy link
Copy Markdown
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?

@0AyanamiRei 0AyanamiRei marked this pull request as draft June 26, 2026 06:04
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: Follow-up review found two issues in the new routine load target-table alter support. First, `AlterRoutineLoadCommand` had an import order regression that could fail FE checkstyle. Second, alter validation only rechecked `PARTIAL_COLUMNS=true` from the current command, which left the effective partial-update state under-validated when the existing job or a `unique_key_update_mode` change required merge-on-write semantics. This change restores import ordering, validates the effective unique key update mode against the destination table, and adds focused FE unit coverage for those cases.

### Release note

Routine Load alter now rejects target-table or unique-key-update changes that are incompatible with partial update requirements.

### Check List (For Author)

- Test: Unit Test
- Behavior changed: Yes
- Does this need documentation: No
@0AyanamiRei 0AyanamiRei marked this pull request as ready for review June 29, 2026 01:11
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter change hit FE checkstyle in CI because one validation error message exceeded the line-length limit and a unit-test import order did not match the FE custom import ordering rule. This commit makes the minimal formatting-only fixes so the branch aligns with FE style checks.

### Release note

None

### Check List (For Author)

- Test: No need to test (formatting-only fix requested by reviewer; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei 0AyanamiRei changed the title [feature](fe) Add routine load target-table alter support [feature](routineload) Add routine load target-table alter support Jun 29, 2026
@sollhui

sollhui commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

/review

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter implementation had a single-use helper for constructing the validation load descriptor snapshot, and the parser branch for table-only alter did not mark the intended phase-one scope. This commit inlines the one-off snapshot construction at the validation call site and documents that the current parser branch only supports target table alteration before future support for combining target-table and property changes.

### Release note

None

### Check List (For Author)

- Test: No need to test (review follow-up only; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed for PR 64878 at head 760890d.

I found one correctness issue: validation can accept an alter that later leaves the routine-load job in partial-update mode on a non-MoW table.

Critical checkpoints:

  • Goal: the PR adds single-table routine-load target-table alteration while preserving stream progress; the implementation largely wires parser, command validation, job mutation, replay, display, and tests, but the partial-update validation path is inconsistent with mutation for one property combination.
  • Scope/focus: the target-table change is small and localized to routine-load command/job/persistence paths.
  • Concurrency/lifecycle: mutation is still gated by the existing paused-job write lock; no new background thread or lock order was introduced.
  • Configuration/session propagation: no new config item; existing routine-load session/job properties are reused.
  • Compatibility/persistence: new log field is backward-readable by current code; target-table id is replayed in Kafka and Kinesis paths.
  • Parallel paths: Kafka and Kinesis both update/replay targetTableId; scheduling/task planning uses the current job tableId.
  • Tests: parser/command/persistence/unit coverage and a Kafka regression were added. I verified git diff --check and mvn -pl fe-core -DskipTests checkstyle:check. I did not run FE compile/unit/regression tests because this checkout lacks thirdparty/installed/bin/protoc and thirdparty/installed.
  • User focus: no additional user-provided focus was present.

Subagent conclusions: optimizer-rewrite proposed OPT-001, which became inline comment MAIN-001. tests-session-config reported no distinct candidate. Convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for the same current ledger/comment set.

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/28345324644

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.63% (40/79) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29129 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17723	4017	4145	4017
q2	2022	319	187	187
q3	10328	1532	851	851
q4	4699	468	341	341
q5	7700	845	582	582
q6	204	173	141	141
q7	776	848	628	628
q8	10199	1487	1606	1487
q9	5907	4480	4460	4460
q10	6772	1809	1503	1503
q11	440	286	248	248
q12	629	430	310	310
q13	18087	3385	2817	2817
q14	265	256	244	244
q15	q16	782	773	706	706
q17	1029	955	1029	955
q18	6797	5786	5453	5453
q19	1173	1277	1096	1096
q20	509	411	263	263
q21	5699	2559	2539	2539
q22	446	356	301	301
Total cold run time: 102186 ms
Total hot run time: 29129 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4418	4256	4290	4256
q2	320	366	227	227
q3	4539	4941	4364	4364
q4	2083	2151	1366	1366
q5	4451	4327	4297	4297
q6	233	181	134	134
q7	1740	1936	1826	1826
q8	2423	2181	2100	2100
q9	8114	8044	8082	8044
q10	4852	4758	4301	4301
q11	565	425	389	389
q12	735	762	646	646
q13	3317	3589	2994	2994
q14	300	305	278	278
q15	q16	758	761	679	679
q17	1350	1344	1328	1328
q18	7947	7410	6831	6831
q19	1137	1104	1129	1104
q20	2274	2215	1948	1948
q21	5268	4573	4537	4537
q22	511	465	402	402
Total cold run time: 57335 ms
Total hot run time: 52051 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 171607 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 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query5	4322	626	484	484
query6	430	183	171	171
query7	4810	553	302	302
query8	334	180	163	163
query9	8757	4085	4079	4079
query10	424	316	261	261
query11	5806	2352	2123	2123
query12	156	102	99	99
query13	1278	579	413	413
query14	6270	5269	4957	4957
query14_1	4327	4295	4289	4289
query15	219	202	179	179
query16	1038	447	432	432
query17	1107	711	604	604
query18	2432	465	337	337
query19	197	181	145	145
query20	113	108	103	103
query21	214	144	116	116
query22	13798	13672	13407	13407
query23	17262	16399	16148	16148
query23_1	16279	16175	16292	16175
query24	7465	1786	1326	1326
query24_1	1337	1283	1325	1283
query25	579	455	388	388
query26	1318	326	174	174
query27	2678	583	345	345
query28	4474	2032	2037	2032
query29	1099	651	520	520
query30	309	235	208	208
query31	1126	1091	946	946
query32	106	64	60	60
query33	547	320	262	262
query34	1167	1109	654	654
query35	775	796	686	686
query36	1414	1390	1241	1241
query37	154	115	92	92
query38	1902	1723	1671	1671
query39	926	936	915	915
query39_1	873	882	896	882
query40	231	126	106	106
query41	69	68	68	68
query42	91	90	88	88
query43	324	322	277	277
query44	1473	817	782	782
query45	216	194	181	181
query46	1075	1199	760	760
query47	2345	2351	2264	2264
query48	404	411	323	323
query49	595	438	326	326
query50	1069	370	267	267
query51	4406	4417	4350	4350
query52	82	83	73	73
query53	244	274	199	199
query54	277	234	211	211
query55	77	73	68	68
query56	261	233	236	233
query57	1428	1435	1302	1302
query58	245	217	223	217
query59	1558	1650	1439	1439
query60	284	256	239	239
query61	182	177	213	177
query62	704	644	573	573
query63	237	193	190	190
query64	2525	773	625	625
query65	4820	4804	4771	4771
query66	1818	460	330	330
query67	28846	28759	28682	28682
query68	3220	1539	931	931
query69	418	308	261	261
query70	1082	1022	991	991
query71	311	238	213	213
query72	2915	2867	2340	2340
query73	890	800	439	439
query74	5133	4990	4751	4751
query75	2601	2541	2180	2180
query76	2308	1201	783	783
query77	392	379	293	293
query78	12392	12431	11997	11997
query79	1407	1137	762	762
query80	1236	454	387	387
query81	514	280	250	250
query82	612	156	117	117
query83	317	276	247	247
query84	264	139	115	115
query85	885	510	438	438
query86	439	325	276	276
query87	1841	1827	1776	1776
query88	3756	2810	2779	2779
query89	426	378	334	334
query90	1870	186	187	186
query91	174	160	137	137
query92	65	62	53	53
query93	1600	1474	874	874
query94	715	352	333	333
query95	669	469	347	347
query96	1139	806	348	348
query97	2683	2660	2554	2554
query98	217	206	201	201
query99	1161	1163	1067	1067
Total cold run time: 257841 ms
Total hot run time: 171607 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.95 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query1	0.01	0.01	0.00
query2	0.10	0.04	0.05
query3	0.25	0.16	0.13
query4	1.60	0.14	0.14
query5	0.24	0.22	0.22
query6	1.26	1.05	1.02
query7	0.03	0.01	0.01
query8	0.06	0.04	0.04
query9	0.39	0.32	0.34
query10	0.58	0.54	0.58
query11	0.18	0.15	0.15
query12	0.18	0.15	0.14
query13	0.48	0.47	0.47
query14	1.02	1.01	0.98
query15	0.61	0.59	0.58
query16	0.33	0.31	0.30
query17	1.08	1.12	1.04
query18	0.22	0.21	0.22
query19	2.05	1.90	1.90
query20	0.01	0.01	0.01
query21	15.44	0.19	0.14
query22	4.95	0.06	0.05
query23	16.13	0.31	0.12
query24	2.98	0.41	0.31
query25	0.11	0.06	0.04
query26	0.74	0.23	0.15
query27	0.05	0.03	0.03
query28	3.53	0.90	0.52
query29	12.50	4.33	3.45
query30	0.28	0.15	0.16
query31	2.77	0.60	0.31
query32	3.22	0.60	0.50
query33	3.17	3.16	3.31
query34	15.51	4.21	3.50
query35	3.48	3.51	3.54
query36	0.54	0.42	0.43
query37	0.10	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.16	0.15
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 96.59 s
Total hot run time: 24.95 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD validation handled unique_key_update_mode and legacy partial_columns with different precedence from the mutation path. An ALTER containing unique_key_update_mode=UPSERT and partial_columns=true could pass validation on a non-MoW table, then be applied as UPDATE_FIXED_COLUMNS. Flexible partial-update ALTERs on non-MoW tables were also rejected by the generic PARTIAL_COLUMNS validation before reaching the flexible partial-update validation path. This change makes generic partial-column validation apply only to fixed partial update mode and makes the mutation path ignore legacy partial_columns when an explicit unique_key_update_mode is present. The routine load alter regression test also declares its polling counters as local variables to satisfy regression framework script checks.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: apache#64878

Problem Summary: The PR pipeline failed in FE checkstyle because a RoutineLoadJob line added for altering unique key update mode exceeded the 120-character limit. Wrap the containsKey call without changing behavior so FE checkstyle can pass.

### Release note

None

### Check List (For Author)

- Test: Manual test
    - ./build.sh --fe -j60
    - git diff --check -- fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadJob.java
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29076 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 48f1b8c98a9525dcaf78df75897067e5faa65bd0, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17744	4043	4030	4030
q2	2061	309	185	185
q3	10276	1403	846	846
q4	4683	466	337	337
q5	7529	842	586	586
q6	190	172	136	136
q7	793	849	631	631
q8	9740	1490	1558	1490
q9	5780	4492	4540	4492
q10	6858	1793	1545	1545
q11	448	276	243	243
q12	642	434	303	303
q13	18131	3382	2743	2743
q14	276	264	249	249
q15	q16	785	782	706	706
q17	1189	1059	879	879
q18	7165	5882	5534	5534
q19	2578	1372	1119	1119
q20	502	409	271	271
q21	5872	2598	2444	2444
q22	441	365	307	307
Total cold run time: 103683 ms
Total hot run time: 29076 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4362	4393	4249	4249
q2	319	349	227	227
q3	4521	4933	4378	4378
q4	2097	2140	1398	1398
q5	4411	4269	4273	4269
q6	230	177	132	132
q7	1769	2077	1659	1659
q8	2454	2163	2099	2099
q9	8232	8118	8055	8055
q10	4821	4804	4340	4340
q11	557	411	577	411
q12	753	745	545	545
q13	3304	3580	3009	3009
q14	314	328	291	291
q15	q16	726	740	646	646
q17	1375	1361	1387	1361
q18	7852	7327	6944	6944
q19	1129	1094	1109	1094
q20	2235	2212	1969	1969
q21	5280	4641	4484	4484
q22	533	472	404	404
Total cold run time: 57274 ms
Total hot run time: 51964 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 172616 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 48f1b8c98a9525dcaf78df75897067e5faa65bd0, data reload: false

query5	4348	635	493	493
query6	445	188	187	187
query7	4974	584	311	311
query8	334	191	171	171
query9	8724	4090	4115	4090
query10	444	311	276	276
query11	5901	2329	2175	2175
query12	157	102	104	102
query13	1260	611	453	453
query14	6248	5341	5022	5022
query14_1	4362	4314	4319	4314
query15	229	207	185	185
query16	1071	469	459	459
query17	1151	750	611	611
query18	2669	485	358	358
query19	206	187	149	149
query20	116	109	107	107
query21	216	148	124	124
query22	13663	13887	13486	13486
query23	17227	16528	16163	16163
query23_1	16310	16315	16272	16272
query24	7603	1797	1310	1310
query24_1	1346	1317	1309	1309
query25	572	481	419	419
query26	1294	329	176	176
query27	2643	601	343	343
query28	4432	2069	2033	2033
query29	1115	636	499	499
query30	324	242	198	198
query31	1119	1079	968	968
query32	110	66	62	62
query33	529	328	270	270
query34	1166	1237	632	632
query35	777	811	691	691
query36	1354	1412	1223	1223
query37	161	124	96	96
query38	1907	1721	1676	1676
query39	933	912	903	903
query39_1	885	900	871	871
query40	238	166	99	99
query41	63	63	63	63
query42	91	88	89	88
query43	337	342	289	289
query44	1491	803	773	773
query45	204	187	177	177
query46	1082	1257	766	766
query47	2324	2342	2219	2219
query48	393	430	305	305
query49	592	433	316	316
query50	1038	351	271	271
query51	4426	4443	4306	4306
query52	80	81	69	69
query53	246	271	192	192
query54	275	214	215	214
query55	75	70	72	70
query56	251	232	214	214
query57	1422	1398	1297	1297
query58	243	212	215	212
query59	1616	1670	1448	1448
query60	290	244	239	239
query61	160	145	158	145
query62	698	652	587	587
query63	232	194	201	194
query64	2558	757	627	627
query65	4833	4807	4815	4807
query66	1763	466	330	330
query67	28853	28886	28707	28707
query68	3095	1673	910	910
query69	406	305	279	279
query70	1070	973	983	973
query71	329	245	224	224
query72	2848	2688	2346	2346
query73	842	816	430	430
query74	5142	4998	4796	4796
query75	2553	2533	2166	2166
query76	2306	1249	837	837
query77	370	402	290	290
query78	12303	12497	11867	11867
query79	1403	1201	790	790
query80	1306	477	403	403
query81	520	282	241	241
query82	630	167	123	123
query83	324	274	256	256
query84	262	145	113	113
query85	893	519	417	417
query86	439	309	296	296
query87	1848	1831	1788	1788
query88	3783	2789	2797	2789
query89	435	397	334	334
query90	1895	190	190	190
query91	176	169	136	136
query92	67	64	58	58
query93	1585	1459	959	959
query94	748	362	328	328
query95	661	470	367	367
query96	1086	781	356	356
query97	2673	2670	2553	2553
query98	215	205	203	203
query99	1153	1131	1033	1033
Total cold run time: 258160 ms
Total hot run time: 172616 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.31 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 48f1b8c98a9525dcaf78df75897067e5faa65bd0, data reload: false

query1	0.01	0.01	0.00
query2	0.10	0.05	0.05
query3	0.26	0.14	0.13
query4	1.60	0.14	0.13
query5	0.24	0.23	0.23
query6	1.27	1.05	1.06
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.37	0.33	0.31
query10	0.56	0.55	0.56
query11	0.19	0.15	0.14
query12	0.18	0.14	0.14
query13	0.47	0.46	0.48
query14	1.03	1.01	1.01
query15	0.62	0.61	0.60
query16	0.31	0.33	0.34
query17	1.12	1.09	1.10
query18	0.22	0.21	0.22
query19	2.08	1.95	1.94
query20	0.02	0.01	0.01
query21	15.43	0.19	0.13
query22	4.99	0.06	0.05
query23	16.13	0.31	0.13
query24	2.96	0.40	0.33
query25	0.12	0.05	0.04
query26	0.74	0.21	0.16
query27	0.04	0.04	0.04
query28	3.59	0.92	0.53
query29	12.51	4.28	3.50
query30	0.29	0.15	0.16
query31	2.77	0.58	0.32
query32	3.24	0.59	0.50
query33	3.17	3.22	3.30
query34	15.36	4.22	3.49
query35	3.59	3.49	3.50
query36	0.56	0.43	0.42
query37	0.10	0.06	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.17	0.16
query41	0.09	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.04	0.04
Total cold run time: 96.79 s
Total hot run time: 25.31 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 51.22% (42/82) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load alter regression test checked deterministic target-table switch rows with direct Groovy assertions and reused local variable names in the same suite scope. CI reported the case as invalid, and the local framework rejected the duplicate variables during Groovy compilation. This records the deterministic source and destination row checks through qt_sql output checks, uses distinct polling counter names, and keeps Kafka topics isolated so repeated local runs do not consume retained messages.

### Release note

None

### Check List (For Author)

- Test: Regression test

    - ./run-regression-test.sh --run -d load_p0/routine_load -s test_routine_load_alter -c 'jdbc:mysql://127.0.0.1:49030/?useLocalSessionState=true&allowLoadLocalInfile=true&zeroDateTimeBehavior=round' -ha 127.0.0.1:48030 -conf enableKafkaTest=true -conf kafka_port=19194 -conf externalEnvIp=127.0.0.1

- Behavior changed: No

- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29371 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17598	3988	3987	3987
q2	1993	317	192	192
q3	10335	1398	828	828
q4	4683	473	338	338
q5	7513	852	566	566
q6	181	171	139	139
q7	759	844	615	615
q8	9344	1658	1669	1658
q9	5580	4582	4473	4473
q10	6792	1763	1533	1533
q11	456	276	241	241
q12	625	424	287	287
q13	18093	3420	2758	2758
q14	266	260	242	242
q15	q16	792	779	710	710
q17	895	933	941	933
q18	7074	5747	5616	5616
q19	1163	1250	1090	1090
q20	493	389	260	260
q21	6217	2842	2584	2584
q22	478	370	321	321
Total cold run time: 101330 ms
Total hot run time: 29371 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5136	4712	4760	4712
q2	345	365	240	240
q3	4880	5272	4774	4774
q4	2087	2139	1399	1399
q5	4785	4840	4640	4640
q6	235	181	124	124
q7	1874	1756	1665	1665
q8	2440	2132	2084	2084
q9	8099	7818	7536	7536
q10	4736	4671	4199	4199
q11	543	384	351	351
q12	729	741	525	525
q13	2956	3407	2786	2786
q14	278	296	250	250
q15	q16	669	706	630	630
q17	1285	1252	1245	1245
q18	7506	6819	6743	6743
q19	1107	1076	1117	1076
q20	2241	2222	1977	1977
q21	5290	4628	4439	4439
q22	515	460	408	408
Total cold run time: 57736 ms
Total hot run time: 51803 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 172483 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 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

query5	4302	609	495	495
query6	438	195	168	168
query7	4818	560	293	293
query8	328	178	162	162
query9	8794	4033	4025	4025
query10	458	317	264	264
query11	5931	2352	2147	2147
query12	156	100	100	100
query13	1267	607	449	449
query14	6236	5290	4937	4937
query14_1	4245	4260	4247	4247
query15	206	198	179	179
query16	993	460	435	435
query17	919	710	565	565
query18	2424	478	347	347
query19	197	181	140	140
query20	111	108	105	105
query21	219	135	113	113
query22	13587	13582	13354	13354
query23	17315	16513	16224	16224
query23_1	16185	16346	16222	16222
query24	7514	1784	1294	1294
query24_1	1344	1299	1319	1299
query25	571	474	397	397
query26	1299	314	175	175
query27	2716	574	322	322
query28	4474	2055	2055	2055
query29	1101	630	527	527
query30	323	241	206	206
query31	1122	1081	975	975
query32	109	65	62	62
query33	563	328	260	260
query34	1182	1106	678	678
query35	805	793	684	684
query36	1426	1457	1246	1246
query37	158	107	94	94
query38	1892	1729	1621	1621
query39	921	913	887	887
query39_1	866	885	871	871
query40	228	123	105	105
query41	70	70	69	69
query42	91	87	95	87
query43	319	323	282	282
query44	1422	797	801	797
query45	202	196	182	182
query46	1078	1236	743	743
query47	2407	2373	2273	2273
query48	386	428	295	295
query49	583	431	325	325
query50	1022	350	276	276
query51	4420	4488	4402	4402
query52	82	82	72	72
query53	256	257	195	195
query54	272	232	211	211
query55	79	72	68	68
query56	260	239	230	230
query57	1432	1419	1314	1314
query58	259	235	224	224
query59	1564	1606	1471	1471
query60	293	264	248	248
query61	168	170	199	170
query62	685	646	592	592
query63	232	181	195	181
query64	2513	747	608	608
query65	4879	4747	4773	4747
query66	1829	457	337	337
query67	29759	29672	29501	29501
query68	3100	1625	882	882
query69	414	296	272	272
query70	1052	952	939	939
query71	303	230	211	211
query72	2928	2669	2391	2391
query73	828	775	429	429
query74	5145	4935	4760	4760
query75	2568	2553	2166	2166
query76	2330	1207	765	765
query77	338	375	274	274
query78	12400	12667	11892	11892
query79	1396	1213	779	779
query80	769	465	389	389
query81	486	285	245	245
query82	573	158	120	120
query83	331	278	248	248
query84	328	144	113	113
query85	904	534	425	425
query86	400	314	281	281
query87	1832	1832	1741	1741
query88	3686	2819	2799	2799
query89	428	393	337	337
query90	1784	179	175	175
query91	170	171	166	166
query92	64	57	55	55
query93	1569	1449	916	916
query94	608	303	313	303
query95	691	470	350	350
query96	1103	816	351	351
query97	2683	2690	2548	2548
query98	216	207	200	200
query99	1209	1171	1024	1024
Total cold run time: 257278 ms
Total hot run time: 172483 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.33 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.13
query5	0.23	0.25	0.22
query6	1.23	1.07	1.07
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.31	0.30
query10	0.58	0.55	0.54
query11	0.19	0.14	0.14
query12	0.18	0.15	0.15
query13	0.47	0.47	0.48
query14	1.02	1.02	1.01
query15	0.61	0.59	0.58
query16	0.31	0.32	0.31
query17	1.09	1.14	1.13
query18	0.22	0.20	0.20
query19	2.08	1.97	1.94
query20	0.01	0.02	0.01
query21	15.44	0.20	0.13
query22	4.80	0.05	0.05
query23	16.13	0.30	0.12
query24	3.02	0.43	0.33
query25	0.10	0.04	0.05
query26	0.73	0.20	0.17
query27	0.03	0.04	0.03
query28	3.51	0.94	0.53
query29	12.50	4.30	3.45
query30	0.27	0.15	0.16
query31	2.77	0.58	0.31
query32	3.22	0.60	0.50
query33	3.13	3.24	3.26
query34	15.58	4.21	3.53
query35	3.55	3.52	3.54
query36	0.57	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.03	0.04	0.03
query40	0.18	0.17	0.15
query41	0.08	0.03	0.02
query42	0.03	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.52 s
Total hot run time: 25.33 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 51.22% (42/82) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 57.32% (47/82) 🎉
Increment coverage report
Complete coverage report

@0AyanamiRei 0AyanamiRei changed the title [feature](routineload) Add routine load target-table alter support [feature](routineload) phase1 : Add routine load target-table alter support Jun 30, 2026
@sollhui

sollhui commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed for PR 64878 at head 0f1be9e.

I did not find any new substantiated issue to raise. The previously reported partial-update precedence issue is already covered by the existing inline thread and appears fixed in the current head: explicit unique_key_update_mode now removes partial_columns from the apply map, and validation only enforces the MoW check for effective UPDATE_FIXED_COLUMNS.

Critical checkpoints:

  • Goal: the PR adds single-table routine-load target-table alteration while preserving stream progress. Current parser, command validation, job mutation, journal replay, show paths, and tests are aligned with that goal.
  • Scope/focus: the implementation is localized to routine-load command/job/persistence paths plus targeted parser, unit, and regression coverage.
  • Concurrency/lifecycle: live mutation remains gated by the existing paused-job write lock; queued stale tasks are filtered by checkTaskInJob after pause clears the task list; no new thread or lock order was introduced.
  • Configuration/session propagation: no new config item was added; existing routine-load properties and Nereids task-info propagation are reused.
  • Compatibility/persistence: targetTableId is Gson-annotated in AlterRoutineLoadJobOperationLog, current-code replay handles missing legacy targetTableId as 0, and both Kafka and Kinesis replay paths apply the new target table id without resetting progress.
  • Parallel paths: Kafka and Kinesis live/replay paths both update targetTableId; task planning and transaction begin use the current job tableId.
  • Tests: parser/command/persistence/unit coverage and an external-Kafka regression cover the target-table switch and the fixed partial-update precedence behavior. I did not run FE build/unit/regression tests because this checkout lacks thirdparty/installed and thirdparty/installed/bin/protoc. I checked added diff lines for trailing whitespace; none were introduced by this PR.
  • User focus: no additional user-provided review focus was present.

Subagent conclusions: optimizer-rewrite reported NO_NEW_VALUABLE_FINDINGS in its focused pass and again in convergence round 1. tests-session-config also reported NO_NEW_VALUABLE_FINDINGS in its focused pass and convergence round 1. No subagent candidates became inline comments, and the final proposed inline comment set is empty.

sollhui
sollhui previously approved these changes Jun 30, 2026

@sollhui sollhui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD previously used the ON target-table syntax and could not combine a target switch with supported job or data-source properties. Add the explicit SET TARGET TABLE syntax, preserve Doris property constraints, validate and apply target/job/source changes atomically, and keep unspecified Kafka and Kinesis default positions unchanged.

### Release note

ALTER ROUTINE LOAD now uses SET TARGET TABLE = "table" and can combine a target table switch with supported PROPERTIES and FROM data-source properties.

### Check List (For Author)

- Test: Regression test / Unit Test / Build
    - FE routine-load and parser unit tests
    - load_p0/routine_load/test_routine_load_alter regression test
    - ./build.sh --fe -j48
- Behavior changed: Yes. ALTER ROUTINE LOAD target-table syntax and composability changed as described above.
- Does this need documentation: Yes (tracked by Related PR apache#64878)
@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Jul 15, 2026
@0AyanamiRei 0AyanamiRei changed the title [feature](routineload) phase1 : Add routine load target-table alter support [feature](routineload) Add routine load target-table alter support Jul 15, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: Routine load target-table alteration validated the target outside the mutation critical section, Kafka datetime default offsets could leak Doris-only properties to librdkafka, and SHOW could combine an old target table name with newly altered job state. Centralize ALTER mutation under the job and target metadata locks, repeat complete target validation before mutation, filter both internal Kafka default-offset properties, and read SHOW state under the job read lock.

### Release note

Fix routine load target-table alteration consistency and Kafka datetime default-offset handling.

### Check List (For Author)

- Test: Unit Test
    - `./run-fe-ut.sh --run org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest,org.apache.doris.load.routineload.RoutineLoadJobTest`
    - `./build.sh --fe -j48`
- Behavior changed: Yes, target-table ALTER is validated atomically, Doris-only Kafka properties are filtered, and SHOW uses a consistent job snapshot
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD target-table switching is supported only for Kafka jobs. Remove the redundant Kinesis implementation and tests, restore the existing Kinesis ALTER behavior, and reject target-table changes for non-Kafka jobs during command validation.

### Release note

ALTER ROUTINE LOAD SET TARGET TABLE supports Kafka Routine Load jobs only.

### Check List (For Author)

- Test: Not run (per request)
- Behavior changed: Yes. Kinesis jobs now explicitly reject target-table changes.
- Does this need documentation: Yes. Document the Kafka-only limitation.
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: Restricting target-table alteration to Kafka restored the old Kinesis modifyProperties override, but RoutineLoadJob now requires subclasses to implement unprotectModifyProperties. This caused FE compilation to fail. Implement the required Kinesis hook by delegating to the existing property mutation path while keeping target-table alteration rejected for non-Kafka jobs.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: Routine Load focused FE UT (71 tests)
    - FE build: ./build.sh --fe --clean -j48
- Behavior changed: No. Kinesis target-table alteration remains unsupported.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants