Skip to content

[fix](fe) Quote dictionary data load identifiers - #67052

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fix-dictionary-identifiers-66594
Open

[fix](fe) Quote dictionary data load identifiers#67052
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fix-dictionary-identifiers-66594

Conversation

@Mryange

@Mryange Mryange commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This change picks #66594 onto master and adapts it to the latest dictionary loading code. Dictionary refresh previously concatenated raw catalog, database, table, and dictionary names into an internal INSERT ... SELECT statement executed by the background loader. Identifier text containing SQL syntax could therefore alter the parsed query structure. The fix quotes and escapes every identifier component with the existing Nereids helper and adds a parser-level unit test to verify that hostile-looking names remain a single source relation.

Issue Number: None

Related PR: apache#66218

Problem Summary: Dictionary refresh rebuilt its internal INSERT SELECT statement by concatenating raw target and source object names. Identifier text containing SQL syntax could therefore change the parsed query structure. Quote and escape every identifier component with the existing Nereids helper, and add a parser-level unit test that verifies hostile-looking names remain one source relation.

Fix dictionary refresh for quoted object names.

- Test: Unit test added; not run locally because the required thirdparty protoc binary is unavailable in the worktree
- Behavior changed: Yes; dictionary load SQL now treats all metadata names strictly as identifiers
- Does this need documentation: No
@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?

@Mryange

Mryange commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

/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 opinion: no additional changes are requested for the current head.

Critical checkpoints:

  • Goal, correctness, and proof: The change prevents dictionary metadata names from changing the internal INSERT ... SELECT structure. Each target/source component is quoted separately, embedded backticks are doubled and decoded back to the original identifier, and the explicit three-part target/source names remain independent of the caller's current catalog or database. The structural unit test checks the base sink, replacement dictionary sink, exactly one source relation, and exact decoded qualifier lists.
  • Scope and clarity: The production change is limited to one shared dictionary-load SQL builder plus the adjacent recovery boundary and one focused unit test. No parallel refresh path still concatenates raw dictionary/source names.
  • Concurrency and lifecycle: The existing atomic LOADING transition still excludes concurrent refreshes. Scheduled-context creation, SQL construction, parsing, command conversion, rule setup, and execution now share the existing status-recovery block; ordinary failures restore the captured OUT_OF_DATE or NORMAL state. Retained database/dictionary identity continues to protect drop-and-recreate races, and no new lock-order or heavy-under-lock work is introduced.
  • Configuration, compatibility, and conditional paths: No configuration, persisted format, FE/BE protocol, rolling-upgrade contract, or transmitted variable changes are introduced. Scheduled, adaptive, create-triggered, and manual refreshes all converge on the same path. The existing conditional error-state, partial-load, abort, and commit behavior is unchanged.
  • Tests and test results: The added parser/sink test covers dots, embedded backticks, whitespace, SQL-looking text, structured target/source parts, and an external default catalog. CheckStyle passed. The current checks do not show an FE compilation or execution of DictionaryManagerTest, and per the review-runner contract no local build or test was run, so this review does not claim the new test passed.
  • Observability, persistence, transactions, and writes: Existing refresh logs, status/result reporting, EditLog version handling, commit/abort flow, and write atomicity are unchanged; no new metric or log is needed for this small serialization fix.
  • Performance and security scope: The added work is linear in six short identifier components and occurs once per refresh. Under the repository threat model, the relevant FE SQL/parser and RBAC boundaries remain intact; identifier text cannot escape its quoted token or redirect the internal target/source binding.
  • Other issues: No additional data-correctness, error-propagation, lifecycle, compatibility, performance, or coverage defect was substantiated.
  • User focus: No additional user-provided focus was supplied; the complete two-file PR was reviewed.
  • Review completion: The review converged in Round 1. Both normal full-scope reviewers and the separate risk-focused reviewer returned NO_NEW_VALUABLE_FINDINGS after their mandatory rechecks, and the main-agent final changed-file/unresolved-candidate sweep found zero accepted or unresolved candidates. This is a comment-only review with zero inline comments.

@Mryange

Mryange commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17567	3070	3076	3070
q2	2178	267	225	225
q3	10134	868	512	512
q4	4674	250	201	201
q5	7675	575	389	389
q6	137	119	91	91
q7	551	501	375	375
q8	9228	929	901	901
q9	3471	2424	2417	2417
q10	6497	848	732	732
q11	401	193	184	184
q12	619	257	204	204
q13	18148	1533	1172	1172
q14	156	156	139	139
q15	q16	434	394	372	372
q17	1321	888	850	850
q18	3053	2239	2268	2239
q19	1132	908	743	743
q20	368	288	206	206
q21	4793	1777	1804	1777
q22	317	264	232	232
Total cold run time: 92854 ms
Total hot run time: 17031 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3434	3373	3358	3358
q2	506	398	366	366
q3	2265	2339	2199	2199
q4	1202	1169	890	890
q5	2159	2132	2111	2111
q6	178	123	88	88
q7	1036	920	915	915
q8	1615	1444	1419	1419
q9	3145	3136	3113	3113
q10	1867	1773	1622	1622
q11	359	272	251	251
q12	455	429	336	336
q13	1475	1541	1173	1173
q14	169	178	169	169
q15	q16	394	396	369	369
q17	3605	3333	3190	3190
q18	4820	4363	4683	4363
q19	865	817	932	817
q20	1049	955	816	816
q21	3795	3094	3269	3094
q22	386	346	322	322
Total cold run time: 34779 ms
Total hot run time: 30981 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81712 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 0804b222ed84621e9e36f7b019ed893db96d9cd4, data reload: false

query5	4290	409	334	334
query6	393	154	131	131
query7	4925	409	245	245
query8	292	126	118	118
query9	8740	2882	2896	2882
query10	428	228	193	193
query11	5415	1053	937	937
query12	119	71	79	71
query13	1198	416	332	332
query14	6080	2208	2102	2102
query14_1	1995	1976	1968	1968
query15	176	117	112	112
query16	972	386	369	369
query17	826	468	341	341
query18	2319	327	226	226
query19	168	137	106	106
query20	71	69	67	67
query21	196	98	85	85
query22	5497	5362	5277	5277
query23	6713	6278	6008	6008
query23_1	6265	6038	6214	6038
query24	7323	1102	772	772
query24_1	791	774	786	774
query25	424	293	249	249
query26	1226	239	131	131
query27	2783	431	251	251
query28	4669	1492	1459	1459
query29	929	432	335	335
query30	250	151	128	128
query31	815	395	325	325
query32	121	67	69	67
query33	441	202	168	168
query34	1031	839	494	494
query35	389	383	323	323
query36	559	582	537	537
query37	156	78	67	67
query38	1004	841	819	819
query39	522	481	466	466
query39_1	466	453	462	453
query40	235	94	82	82
query41	61	59	58	58
query42	76	72	72	72
query43	243	248	208	208
query44	1043	555	554	554
query45	109	108	104	104
query46	768	842	539	539
query47	762	768	714	714
query48	321	305	244	244
query49	552	253	187	187
query50	748	259	198	198
query51	8139	8177	8043	8043
query52	69	65	58	58
query53	188	192	150	150
query54	234	174	175	174
query55	77	68	55	55
query56	211	207	202	202
query57	633	637	651	637
query58	201	166	161	161
query59	1214	1202	1103	1103
query60	222	181	168	168
query61	125	113	136	113
query62	351	209	170	170
query63	172	137	139	137
query64	2696	733	625	625
query65	1642	1562	1551	1551
query66	1884	251	247	247
query67	9688	9545	9543	9543
query68	2778	1227	756	756
query69	349	235	183	183
query70	691	610	617	610
query71	247	177	164	164
query72	2335	1723	1592	1592
query73	644	582	337	337
query74	1569	1218	1098	1098
query75	1177	1106	944	944
query76	2292	756	550	550
query77	248	241	213	213
query78	3789	3594	3097	3097
query79	2398	795	595	595
query80	1590	338	291	291
query81	476	154	130	130
query82	815	133	95	95
query83	282	212	188	188
query84	288	108	86	86
query85	783	356	291	291
query86	450	171	167	167
query87	1011	977	887	887
query88	2785	2096	2110	2096
query89	291	201	183	183
query90	1960	127	128	127
query91	130	122	103	103
query92	83	70	67	67
query93	1426	1069	688	688
query94	698	253	210	210
query95	537	320	225	225
query96	842	630	276	276
query97	1044	1074	964	964
query98	146	133	130	130
query99	464	352	314	314
Total cold run time: 177674 ms
Total hot run time: 81712 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.07	0.03	0.03
query3	0.25	0.11	0.11
query4	1.60	0.11	0.09
query5	0.17	0.16	0.17
query6	1.29	0.68	0.70
query7	0.03	0.01	0.00
query8	0.04	0.03	0.03
query9	0.29	0.21	0.23
query10	0.35	0.35	0.34
query11	0.16	0.12	0.12
query12	0.15	0.12	0.12
query13	0.29	0.32	0.29
query14	0.44	0.45	0.45
query15	0.36	0.34	0.34
query16	0.22	0.22	0.22
query17	0.66	0.71	0.68
query18	0.18	0.17	0.16
query19	1.18	1.18	1.11
query20	0.02	0.01	0.01
query21	15.44	0.15	0.13
query22	5.06	0.05	0.04
query23	16.22	0.26	0.10
query24	2.98	0.31	0.24
query25	0.12	0.04	0.03
query26	0.77	0.17	0.11
query27	0.03	0.03	0.02
query28	3.60	0.53	0.27
query29	12.49	3.13	2.56
query30	0.25	0.12	0.12
query31	2.75	0.35	0.18
query32	3.53	0.31	0.23
query33	1.54	1.44	1.38
query34	15.36	2.17	1.75
query35	1.77	1.72	1.73
query36	0.44	0.29	0.29
query37	0.06	0.04	0.04
query38	0.05	0.03	0.02
query39	0.04	0.02	0.03
query40	0.11	0.08	0.08
query41	0.08	0.02	0.02
query42	0.03	0.03	0.02
query43	0.03	0.03	0.02
Total cold run time: 90.5 s
Total hot run time: 14.54 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 2.66% (13/488) 🎉
Increment coverage report
Complete coverage report

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.

3 participants