Skip to content

Conversation

@Ryan19929
Copy link
Contributor

@Ryan19929 Ryan19929 commented Jan 6, 2026

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:
When restoring a view to a different database, the current implementation incorrectly replaces all database names in the view definition with the target database name. This breaks cross-database references.

Example:

  • Original: view_db has a view referencing tables from both base_db and view_db
  SELECT * FROM `internal`.`base_db`.`table1` 
  JOIN `internal`.`view_db`.`table2`
  • After restore to restore_db (BEFORE this PR):
  SELECT * FROM `internal`.`restore_db`.`table1`  -- ❌ Wrong! Should be base_db
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct
  • After restore to restore_db (AFTER this PR):
  SELECT * FROM `internal`.`base_db`.`table1`     -- ✅ Correct! Preserved
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct

Root Cause:
The regex pattern (?<=\internal`\.`)([^\`]+)(?=`\.`)` matches any database name, not just the source database name.

Release note

None

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.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

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

@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?

@Ryan19929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17617	4243	4067	4067
q2	2080	359	256	256
q3	10119	1334	742	742
q4	10205	808	313	313
q5	7510	2090	1809	1809
q6	187	178	140	140
q7	936	799	661	661
q8	9275	1405	1118	1118
q9	4851	4513	4573	4513
q10	6737	1801	1388	1388
q11	530	314	298	298
q12	668	769	586	586
q13	17820	3876	3054	3054
q14	292	293	277	277
q15	565	501	510	501
q16	701	680	652	652
q17	668	801	553	553
q18	6601	6345	6933	6345
q19	1156	1089	611	611
q20	458	406	263	263
q21	3178	2609	2415	2415
q22	1136	1091	1024	1024
Total cold run time: 103290 ms
Total hot run time: 31586 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4294	4426	4311	4311
q2	322	414	340	340
q3	2231	2755	2468	2468
q4	1400	1902	1419	1419
q5	4472	4407	4372	4372
q6	255	172	126	126
q7	1952	1958	1775	1775
q8	2563	2289	2346	2289
q9	7299	7131	7360	7131
q10	2504	2655	2353	2353
q11	548	507	457	457
q12	695	809	604	604
q13	3558	4006	3407	3407
q14	273	317	295	295
q15	525	484	490	484
q16	590	658	653	653
q17	1083	1222	1299	1222
q18	7603	7442	7239	7239
q19	821	770	813	770
q20	1938	1964	1835	1835
q21	4577	4276	4188	4188
q22	1112	1023	1021	1021
Total cold run time: 50615 ms
Total hot run time: 48759 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172546 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 861cb615d93a408866a4265279a334bc5164a27b, data reload: false

query5	4374	580	431	431
query6	338	232	206	206
query7	4214	445	263	263
query8	343	257	256	256
query9	8753	2643	2656	2643
query10	515	367	321	321
query11	15312	15148	14974	14974
query12	193	116	114	114
query13	1259	487	379	379
query14	6080	2968	2736	2736
query14_1	2639	2595	2623	2595
query15	207	197	184	184
query16	1003	480	451	451
query17	1115	684	572	572
query18	2439	435	376	376
query19	227	214	190	190
query20	124	116	112	112
query21	218	139	119	119
query22	3889	3890	4013	3890
query23	16101	15747	15198	15198
query23_1	15649	15502	15363	15363
query24	7457	1547	1169	1169
query24_1	1191	1155	1193	1155
query25	544	440	391	391
query26	1236	279	148	148
query27	2757	441	304	304
query28	4528	2141	2128	2128
query29	758	522	433	433
query30	313	243	212	212
query31	781	639	560	560
query32	75	70	68	68
query33	524	329	279	279
query34	906	863	516	516
query35	753	782	696	696
query36	866	880	765	765
query37	127	92	76	76
query38	2723	2699	2664	2664
query39	788	750	731	731
query39_1	718	718	702	702
query40	218	138	116	116
query41	68	64	63	63
query42	109	105	104	104
query43	463	447	406	406
query44	1308	740	730	730
query45	196	185	176	176
query46	849	936	590	590
query47	1431	1433	1376	1376
query48	304	329	249	249
query49	603	417	316	316
query50	645	267	200	200
query51	3794	3862	3766	3766
query52	105	112	96	96
query53	292	332	270	270
query54	281	255	242	242
query55	77	80	77	77
query56	285	299	318	299
query57	1003	1008	914	914
query58	272	276	255	255
query59	2098	2148	2152	2148
query60	323	317	304	304
query61	165	161	170	161
query62	426	352	333	333
query63	293	262	271	262
query64	5023	1425	1104	1104
query65	3790	3739	3748	3739
query66	1485	425	310	310
query67	14777	14984	15045	14984
query68	5818	1004	713	713
query69	522	352	326	326
query70	1046	974	893	893
query71	352	305	279	279
query72	6250	3398	3467	3398
query73	754	726	313	313
query74	8829	8768	8511	8511
query75	2847	2813	2438	2438
query76	3895	1054	662	662
query77	519	368	266	266
query78	9619	10051	9125	9125
query79	1219	915	593	593
query80	612	572	470	470
query81	505	267	229	229
query82	227	148	112	112
query83	265	254	241	241
query84	263	120	109	109
query85	890	491	453	453
query86	398	338	321	321
query87	2871	2890	2763	2763
query88	3123	2246	2207	2207
query89	390	346	324	324
query90	2186	157	154	154
query91	171	165	142	142
query92	82	67	64	64
query93	1717	889	531	531
query94	593	324	294	294
query95	578	377	297	297
query96	569	454	207	207
query97	2318	2374	2306	2306
query98	230	200	195	195
query99	577	582	544	544
Total cold run time: 251942 ms
Total hot run time: 172546 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.04
query2	0.10	0.05	0.05
query3	0.26	0.09	0.08
query4	1.60	0.11	0.11
query5	0.25	0.26	0.25
query6	1.15	0.67	0.65
query7	0.03	0.03	0.02
query8	0.05	0.03	0.04
query9	0.57	0.50	0.49
query10	0.56	0.54	0.56
query11	0.14	0.10	0.09
query12	0.15	0.11	0.10
query13	0.60	0.58	0.59
query14	0.96	0.95	0.94
query15	0.79	0.77	0.78
query16	0.39	0.39	0.42
query17	1.00	1.04	1.05
query18	0.24	0.21	0.22
query19	1.91	1.81	1.76
query20	0.02	0.01	0.01
query21	15.44	0.29	0.13
query22	5.20	0.05	0.05
query23	15.98	0.29	0.10
query24	1.41	0.84	0.29
query25	0.13	0.08	0.09
query26	0.14	0.13	0.13
query27	0.06	0.06	0.04
query28	4.46	1.05	0.88
query29	12.60	3.94	3.15
query30	0.28	0.14	0.12
query31	2.82	0.66	0.41
query32	3.25	0.56	0.46
query33	3.14	2.97	3.04
query34	16.84	5.21	4.45
query35	4.47	4.48	4.50
query36	0.65	0.50	0.49
query37	0.12	0.07	0.07
query38	0.07	0.04	0.04
query39	0.05	0.03	0.03
query40	0.17	0.14	0.13
query41	0.10	0.04	0.04
query42	0.05	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 98.29 s
Total hot run time: 26.75 s

@Ryan19929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17592	4190	4062	4062
q2	2014	361	252	252
q3	10151	1255	709	709
q4	10210	867	322	322
q5	7516	2079	1883	1883
q6	194	174	143	143
q7	923	790	663	663
q8	9290	1342	1188	1188
q9	4854	4661	4494	4494
q10	6791	1777	1416	1416
q11	542	298	285	285
q12	683	740	607	607
q13	17771	3853	3090	3090
q14	282	294	290	290
q15	596	509	502	502
q16	673	672	648	648
q17	673	748	581	581
q18	6467	6304	6349	6304
q19	1089	967	597	597
q20	399	363	255	255
q21	2989	2375	2276	2276
q22	1069	1011	980	980
Total cold run time: 102768 ms
Total hot run time: 31547 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4109	4100	4049	4049
q2	322	419	329	329
q3	2104	2577	2215	2215
q4	1309	1780	1275	1275
q5	4080	3975	4020	3975
q6	222	177	134	134
q7	1870	1833	1662	1662
q8	2925	2744	2368	2368
q9	7204	7115	7207	7115
q10	2601	2701	2327	2327
q11	546	475	449	449
q12	781	782	638	638
q13	3658	4099	3358	3358
q14	293	308	288	288
q15	565	625	528	528
q16	680	676	633	633
q17	1154	1269	1404	1269
q18	8128	7953	7809	7809
q19	924	851	922	851
q20	2080	2091	1953	1953
q21	4774	4498	4347	4347
q22	1038	1029	989	989
Total cold run time: 51367 ms
Total hot run time: 48561 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172214 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 be265ab8ff1bd7c860347187b41a5b849f431466, data reload: false

query5	4428	604	429	429
query6	327	221	221	221
query7	4224	453	269	269
query8	344	251	234	234
query9	8740	2651	2674	2651
query10	532	354	326	326
query11	15215	15272	14874	14874
query12	179	117	117	117
query13	1269	492	390	390
query14	6075	2956	2704	2704
query14_1	2664	2628	2625	2625
query15	208	197	180	180
query16	1013	466	444	444
query17	1116	680	590	590
query18	2456	448	350	350
query19	252	226	201	201
query20	126	118	117	117
query21	222	157	118	118
query22	4058	4091	3919	3919
query23	15866	15520	15278	15278
query23_1	15543	15342	15363	15342
query24	7360	1566	1187	1187
query24_1	1215	1185	1204	1185
query25	575	490	461	461
query26	1248	264	152	152
query27	2776	456	287	287
query28	4559	2134	2140	2134
query29	775	563	434	434
query30	299	243	209	209
query31	763	643	561	561
query32	79	75	72	72
query33	530	345	279	279
query34	880	865	524	524
query35	743	781	689	689
query36	848	886	768	768
query37	126	90	72	72
query38	2668	2730	2672	2672
query39	788	759	716	716
query39_1	707	718	720	718
query40	215	139	117	117
query41	66	62	63	62
query42	104	100	101	100
query43	449	472	424	424
query44	1279	730	722	722
query45	186	185	176	176
query46	856	948	603	603
query47	1438	1386	1288	1288
query48	313	323	254	254
query49	598	449	328	328
query50	630	279	198	198
query51	3743	3747	3712	3712
query52	109	107	94	94
query53	316	323	278	278
query54	279	253	245	245
query55	75	72	71	71
query56	291	296	308	296
query57	1035	955	942	942
query58	274	249	255	249
query59	2132	2199	2154	2154
query60	307	313	299	299
query61	163	161	161	161
query62	391	347	326	326
query63	309	261	280	261
query64	5007	1290	988	988
query65	3813	3699	3710	3699
query66	1444	420	294	294
query67	15062	15106	14568	14568
query68	4725	996	716	716
query69	512	350	314	314
query70	1055	963	927	927
query71	364	295	270	270
query72	6000	3442	3712	3442
query73	754	726	296	296
query74	8820	8715	8617	8617
query75	2790	2797	2465	2465
query76	3890	1065	644	644
query77	530	374	273	273
query78	9812	9769	9173	9173
query79	1575	903	582	582
query80	1003	554	466	466
query81	559	264	235	235
query82	414	148	108	108
query83	269	256	244	244
query84	252	115	108	108
query85	918	516	447	447
query86	450	342	321	321
query87	2872	2898	2731	2731
query88	3238	2232	2202	2202
query89	390	343	325	325
query90	2035	153	149	149
query91	176	163	141	141
query92	76	71	61	61
query93	1404	917	532	532
query94	620	276	288	276
query95	572	320	351	320
query96	584	452	203	203
query97	2316	2406	2298	2298
query98	231	201	203	201
query99	559	564	535	535
Total cold run time: 251341 ms
Total hot run time: 172214 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.05
query2	0.10	0.04	0.04
query3	0.26	0.09	0.09
query4	1.61	0.12	0.11
query5	0.27	0.25	0.26
query6	1.15	0.68	0.65
query7	0.03	0.02	0.03
query8	0.06	0.04	0.05
query9	0.57	0.51	0.49
query10	0.55	0.55	0.56
query11	0.15	0.10	0.10
query12	0.15	0.11	0.11
query13	0.62	0.59	0.60
query14	0.95	0.96	0.93
query15	0.80	0.76	0.79
query16	0.41	0.41	0.42
query17	1.06	1.06	1.04
query18	0.23	0.22	0.22
query19	1.86	1.80	1.81
query20	0.01	0.02	0.01
query21	15.43	0.26	0.13
query22	5.04	0.05	0.05
query23	15.93	0.29	0.10
query24	1.06	0.67	0.32
query25	0.08	0.07	0.08
query26	0.15	0.14	0.13
query27	0.07	0.06	0.05
query28	4.06	1.06	0.88
query29	12.61	3.86	3.15
query30	0.30	0.14	0.12
query31	2.82	0.66	0.40
query32	3.24	0.57	0.45
query33	2.99	2.96	3.05
query34	16.84	5.08	4.44
query35	4.46	4.44	4.50
query36	0.67	0.50	0.49
query37	0.11	0.06	0.07
query38	0.07	0.04	0.04
query39	0.04	0.04	0.04
query40	0.17	0.15	0.14
query41	0.10	0.03	0.03
query42	0.05	0.04	0.03
query43	0.04	0.04	0.03
Total cold run time: 97.23 s
Total hot run time: 26.81 s

@Ryan19929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18132	4364	4105	4105
q2	2065	353	240	240
q3	10170	1292	712	712
q4	10211	838	319	319
q5	7521	2110	1839	1839
q6	187	173	140	140
q7	916	784	657	657
q8	9264	1317	1190	1190
q9	4870	4704	4690	4690
q10	6824	1792	1400	1400
q11	532	300	296	296
q12	703	746	612	612
q13	17769	3823	3089	3089
q14	294	295	297	295
q15	578	514	500	500
q16	700	678	636	636
q17	662	816	477	477
q18	6832	6505	6376	6376
q19	1099	974	615	615
q20	412	380	255	255
q21	3020	2477	2306	2306
q22	1043	995	943	943
Total cold run time: 103804 ms
Total hot run time: 31692 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4109	4080	4076	4076
q2	315	388	326	326
q3	2102	2618	2195	2195
q4	1298	1730	1330	1330
q5	4098	3977	4024	3977
q6	212	171	130	130
q7	1870	1809	1849	1809
q8	2668	2472	2490	2472
q9	7239	7142	7117	7117
q10	2550	2739	2307	2307
q11	574	481	462	462
q12	774	803	605	605
q13	3606	4118	3351	3351
q14	291	402	302	302
q15	557	501	498	498
q16	698	705	620	620
q17	1169	1392	1490	1392
q18	7971	7980	7785	7785
q19	879	896	899	896
q20	2012	2038	2020	2020
q21	4834	4535	4381	4381
q22	1051	1016	999	999
Total cold run time: 50877 ms
Total hot run time: 49050 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172754 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 9dcd68617cc1b9f3dc077b16b30fe3513bc2f204, data reload: false

query5	4557	603	454	454
query6	330	237	213	213
query7	4237	468	280	280
query8	346	260	271	260
query9	8769	2665	2688	2665
query10	528	363	337	337
query11	15284	15149	14861	14861
query12	176	116	116	116
query13	1267	491	400	400
query14	6334	3013	2728	2728
query14_1	2809	2643	2651	2643
query15	195	188	172	172
query16	988	473	487	473
query17	1079	652	553	553
query18	2531	433	332	332
query19	227	221	190	190
query20	126	122	111	111
query21	214	137	129	129
query22	3910	3917	3796	3796
query23	16178	15542	15370	15370
query23_1	15380	15386	15533	15386
query24	7390	1550	1193	1193
query24_1	1229	1182	1206	1182
query25	581	485	427	427
query26	1261	269	166	166
query27	2739	452	295	295
query28	4545	2161	2145	2145
query29	835	580	476	476
query30	309	246	218	218
query31	778	619	563	563
query32	80	74	74	74
query33	553	358	300	300
query34	872	870	525	525
query35	736	787	711	711
query36	844	869	837	837
query37	140	100	83	83
query38	2761	2721	2662	2662
query39	785	760	726	726
query39_1	745	715	713	713
query40	223	138	123	123
query41	72	68	70	68
query42	105	103	102	102
query43	435	491	420	420
query44	1307	727	731	727
query45	189	210	190	190
query46	885	983	591	591
query47	1372	1455	1270	1270
query48	319	334	246	246
query49	619	424	353	353
query50	640	292	207	207
query51	3829	3786	3718	3718
query52	110	109	96	96
query53	289	333	277	277
query54	314	276	268	268
query55	78	86	73	73
query56	318	307	325	307
query57	954	981	892	892
query58	281	263	284	263
query59	2172	2201	1964	1964
query60	349	367	300	300
query61	163	178	153	153
query62	403	372	309	309
query63	300	267	265	265
query64	4972	1295	995	995
query65	3810	3710	3761	3710
query66	1409	430	317	317
query67	15035	15759	14927	14927
query68	7372	980	712	712
query69	500	350	315	315
query70	1031	961	947	947
query71	381	296	281	281
query72	6004	3383	3419	3383
query73	762	718	302	302
query74	8711	8724	8593	8593
query75	2827	2839	2495	2495
query76	3782	1060	646	646
query77	539	359	287	287
query78	9676	9844	9126	9126
query79	1257	896	573	573
query80	654	586	490	490
query81	526	263	228	228
query82	208	145	113	113
query83	266	257	233	233
query84	249	123	109	109
query85	887	499	465	465
query86	391	331	283	283
query87	2908	2885	2709	2709
query88	3124	2207	2228	2207
query89	378	357	338	338
query90	2069	161	144	144
query91	171	169	143	143
query92	76	68	66	66
query93	1076	888	542	542
query94	563	315	298	298
query95	574	375	302	302
query96	595	459	207	207
query97	2313	2389	2398	2389
query98	241	201	195	195
query99	573	589	514	514
Total cold run time: 253032 ms
Total hot run time: 172754 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.04
query2	0.09	0.04	0.05
query3	0.26	0.10	0.08
query4	1.61	0.11	0.11
query5	0.27	0.24	0.27
query6	1.14	0.67	0.65
query7	0.04	0.02	0.03
query8	0.05	0.04	0.04
query9	0.58	0.51	0.50
query10	0.56	0.54	0.55
query11	0.15	0.10	0.10
query12	0.14	0.11	0.11
query13	0.60	0.59	0.59
query14	0.95	0.96	0.95
query15	0.80	0.77	0.80
query16	0.40	0.39	0.41
query17	1.00	1.06	1.05
query18	0.23	0.22	0.22
query19	1.96	1.88	1.78
query20	0.02	0.01	0.01
query21	15.44	0.26	0.14
query22	5.39	0.06	0.05
query23	16.08	0.29	0.11
query24	1.12	0.55	0.23
query25	0.08	0.06	0.08
query26	0.15	0.14	0.13
query27	0.06	0.06	0.05
query28	3.55	1.09	0.91
query29	12.59	3.94	3.10
query30	0.28	0.14	0.13
query31	2.82	0.66	0.40
query32	3.24	0.58	0.46
query33	2.98	3.10	2.98
query34	16.71	5.08	4.49
query35	4.45	4.46	4.50
query36	0.67	0.51	0.49
query37	0.11	0.06	0.06
query38	0.07	0.04	0.04
query39	0.05	0.03	0.04
query40	0.18	0.14	0.14
query41	0.08	0.04	0.03
query42	0.04	0.04	0.03
query43	0.05	0.04	0.03
Total cold run time: 97.09 s
Total hot run time: 26.78 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (2/2) 🎉
Increment coverage report
Complete coverage report

@Ryan19929
Copy link
Contributor Author

run p0

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (2/2) 🎉
Increment coverage report
Complete coverage report

Copy link
Contributor

@dataroaring dataroaring left a comment

Choose a reason for hiding this comment

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

LGTM

@dataroaring dataroaring added dev/4.0.x dev/3.1.x usercase Important user case type label labels Jan 7, 2026
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

PR approved by anyone and no changes requested.

@w41ter w41ter merged commit c16527b into apache:master Jan 8, 2026
32 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 8, 2026
#59580)

When restoring a view to a different database, the current
implementation incorrectly replaces **all** database names in the view
definition with the target database name. This breaks cross-database
references.

**Example:**
- Original: `view_db` has a view referencing tables from both `base_db`
and `view_db`
```sql
  SELECT * FROM `internal`.`base_db`.`table1` 
  JOIN `internal`.`view_db`.`table2`
```
  - After restore to `restore_db` (BEFORE this PR):
```sql
  SELECT * FROM `internal`.`restore_db`.`table1`  -- ❌ Wrong! Should be base_db
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct
```
  - After restore to `restore_db` (AFTER this PR):
```sql
  SELECT * FROM `internal`.`base_db`.`table1`     -- ✅ Correct! Preserved
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct
```
  **Root Cause:**
The regex pattern `(?<=\`internal\`\\.\`)([^\`]+)(?=\`\\.\`)` matches
**any** database name, not just the source database name.
@Ryan19929 Ryan19929 deleted the fix-restore-view branch January 8, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.1.x dev/3.1.x-conflict dev/4.0.x reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants