Skip to content

[fix](function) Handle case-insensitive auto partition arguments - #67121

Open
Mryange wants to merge 2 commits into
apache:masterfrom
Mryange:fix-auto-partition-case
Open

[fix](function) Handle case-insensitive auto partition arguments#67121
Mryange wants to merge 2 commits into
apache:masterfrom
Mryange:fix-auto-partition-case

Conversation

@Mryange

@Mryange Mryange commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

AUTO_PARTITION_NAME accepted case-insensitive list and range arguments in FE, but BE compared them case-sensitively. Uppercase LIST was incorrectly routed to the range implementation and could access a missing third argument, causing a BE core. The BE now normalizes partition type and range granularity arguments before dispatch, with unit coverage for mixed-case inputs.

@Mryange

Mryange commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

/review

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

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

Automated review result: request changes

I found two blocking issues: FE and BE still disagree on locale-dependent keyword normalization, leaving an FE-accepted two-argument call on the BE crash path; and the added BE unit test fails before it can prove the fix, then still uses a row shape that cannot independently exercise the cases.

Critical checkpoint conclusions:

  • Goal and proof: the BE change handles locale-independent ASCII case variants, but does not fully align with FE accepted-input semantics; the new test does not currently provide valid proof.
  • Scope/focus: the production diff is compact and focused. Fixing FE normalization and restructuring the test are both required to complete the stated goal.
  • Concurrency: the function is stateless and uses block-local data; no shared-state, lock-order, or atomic concern applies.
  • Lifecycle/static initialization: no lifecycle, ownership-cycle, destructor, or cross-TU static initialization change is introduced.
  • Configuration: no configuration item or dynamic-reload behavior is added.
  • Compatibility: no symbol, protocol, storage-format, or persisted-data change is present. Exact comparisons preserve locale-independent FE-valid tokens and reject existing invalid prefixes; locale parity remains the compatibility gap.
  • Parallel paths: Nereids literal validation, FE literal translation, BE constant/mixed execution, constant folding, list dispatch, and all six range granularities were traced. There is no separate unvalidated legacy scalar path.
  • Conditional/error handling: the normalized list/range branches are otherwise consistent with FE's literal invariant, but the locale mismatch can still select range for a two-argument FE-accepted list call and index the missing third argument.
  • Test coverage: existing regressions cover lowercase granularities and invalid prefixes. The new mixed-case unit test must use the non-nullable result type and independent one-row constant-literal cases; Turkish-default-locale coverage is also needed for FE/BE parity.
  • Test results: the new expected results were reviewed against check_function and the implementation and are not executable as written. No repository builds/tests were run because this review runner explicitly prohibits them; current live checks do not include BE UT execution.
  • Observability: no new distributed or operational path requires logs or metrics.
  • Transactions/persistence: no transaction, EditLog, failover, version-visibility, or persistence behavior is touched.
  • Data writes: no data-write, atomicity, crash-recovery, or MoW behavior is involved.
  • FE-BE variables: no new transmitted field is added; the defect is inconsistent normalization of the same transmitted raw literal.
  • Performance/memory: two tiny once-per-block strings are immaterial; no significant allocation, MemTracker, copy, or hot-loop issue was found.
  • Build hygiene: the standard include is confined to a .cpp; no hub header, PCH, gate table, explicit instantiation, source-including test, or unity-skip rule is affected.
  • User focus: no additional user-provided focus was supplied.

Review completion: three permitted rounds were completed. The final complete-review and risk-focused reviewers both returned NO_NEW_VALUABLE_FINDINGS; all candidates were accepted, merged, or dismissed with evidence, so the review converged with the two inline issues below.

[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
// partition type is list|range
if (std::strncmp(partition_type, "list", 4) == 0) {
if (partition_type == "list") {

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.

[P1] Keep FE and BE keyword normalization locale-independent. FE still validates both literals with parameterless Java String.toLowerCase(), while this byte-wise C-locale transform only canonicalizes ASCII. With a Turkish-default FE, LİST.toLowerCase() is list, so auto_partition_name('LİST', 'x') is accepted as a two-argument list call; the raw literal is transmitted unchanged, becomes lİst here, misses this branch, and the range path indexes the missing third argument. MİNUTE has the same FE-accepted/BE-unmatched split. Please use Locale.ROOT in FE validation or transmit the validated canonical token, and add Turkish-default-locale coverage.

{{"RANGE", "MONTH", "2022-12-12 19:20:30"}, "p20221201000000"},
{{"rAnGe", "dAy", "2022-12-12 19:20:30"}, "p20221212000000"},
};
ASSERT_TRUE(check_function<DataTypeString, true>("auto_partition_name", range_input_types,

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.

[P1] Make these checks use the function's real result and literal shapes. Both calls request Nullable(String) through <DataTypeString, true>, but auto_partition_name declares non-nullable String, so the function builder rejects them before execution. With that corrected, the plain input descriptors still create two-row non-const columns while the implementation reads dispatch and range granularity only from row 0. Both range rows therefore execute MONTH, making the second actual result p20221201000000 rather than p20221212000000; LiSt/rAnGe/dAy in row 2 never independently control the paths they claim to test. Please use non-nullable check_function<DataTypeString> calls and split each casing into a separate one-row invocation, marking production-literal arguments constant.

@Mryange
Mryange dismissed github-actions[bot]’s stale review August 25, 2026 11:03

土耳其语?不管。
case其实也不需要管。

@Mryange

Mryange commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17575	3016	3002	3002
q2	2095	254	230	230
q3	10249	869	514	514
q4	4667	248	206	206
q5	7674	564	390	390
q6	139	115	99	99
q7	543	513	384	384
q8	9242	908	969	908
q9	3490	2415	2406	2406
q10	6495	890	719	719
q11	396	192	181	181
q12	615	255	192	192
q13	18134	1533	1152	1152
q14	161	149	141	141
q15	q16	439	401	370	370
q17	1335	856	776	776
q18	3066	2263	2250	2250
q19	1103	953	783	783
q20	385	283	210	210
q21	5040	1674	1853	1674
q22	317	266	228	228
Total cold run time: 93160 ms
Total hot run time: 16815 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3403	3335	3344	3335
q2	510	382	358	358
q3	2208	2316	2145	2145
q4	1181	1165	892	892
q5	2175	2120	2092	2092
q6	170	119	88	88
q7	1088	913	873	873
q8	1598	1408	1427	1408
q9	3130	3095	3073	3073
q10	1879	1803	1614	1614
q11	349	266	254	254
q12	453	420	334	334
q13	1514	1523	1165	1165
q14	173	164	157	157
q15	q16	383	394	360	360
q17	3641	3333	3198	3198
q18	4859	4418	4692	4418
q19	1068	822	961	822
q20	995	995	838	838
q21	3704	3053	3176	3053
q22	391	347	315	315
Total cold run time: 34872 ms
Total hot run time: 30792 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81635 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 9c7a47d4cc4b09a192d6e5cc5b612f5219809da8, data reload: false

query5	4287	408	327	327
query6	377	136	137	136
query7	4970	403	233	233
query8	293	125	112	112
query9	8674	2854	2846	2846
query10	396	223	183	183
query11	5398	1030	906	906
query12	118	67	69	67
query13	1188	436	313	313
query14	6067	2186	2070	2070
query14_1	1934	1896	1930	1896
query15	172	110	110	110
query16	943	361	350	350
query17	773	441	335	335
query18	2320	321	230	230
query19	154	132	111	111
query20	69	67	70	67
query21	207	100	86	86
query22	5395	5536	5284	5284
query23	6563	6249	5982	5982
query23_1	6028	6102	6190	6102
query24	7345	1109	742	742
query24_1	766	734	797	734
query25	400	283	233	233
query26	1213	226	131	131
query27	2788	438	253	253
query28	4651	1518	1496	1496
query29	921	431	330	330
query30	249	142	128	128
query31	822	389	322	322
query32	128	73	70	70
query33	444	220	171	171
query34	1022	836	491	491
query35	405	405	336	336
query36	589	578	493	493
query37	117	80	66	66
query38	987	843	825	825
query39	501	458	476	458
query39_1	454	468	462	462
query40	199	88	75	75
query41	55	51	49	49
query42	73	71	71	71
query43	233	237	210	210
query44	1007	544	550	544
query45	104	105	100	100
query46	772	847	517	517
query47	766	760	717	717
query48	299	317	235	235
query49	546	244	190	190
query50	731	269	198	198
query51	8035	7994	7960	7960
query52	67	69	63	63
query53	193	195	146	146
query54	234	174	162	162
query55	75	61	55	55
query56	202	182	172	172
query57	677	774	667	667
query58	191	173	178	173
query59	1206	1246	1076	1076
query60	248	196	184	184
query61	162	135	141	135
query62	370	204	177	177
query63	178	152	141	141
query64	2853	718	579	579
query65	1634	1642	1623	1623
query66	1870	253	211	211
query67	10146	9782	9731	9731
query68	3022	1242	758	758
query69	341	229	188	188
query70	685	601	616	601
query71	252	178	158	158
query72	2304	1741	1547	1547
query73	656	562	323	323
query74	2002	1226	1123	1123
query75	1198	1093	947	947
query76	2365	757	529	529
query77	253	253	214	214
query78	3896	3775	3263	3263
query79	2788	834	578	578
query80	1553	323	269	269
query81	500	154	128	128
query82	632	125	101	101
query83	282	203	188	188
query84	297	112	88	88
query85	799	349	300	300
query86	387	182	174	174
query87	1015	967	882	882
query88	2781	2104	2101	2101
query89	296	190	175	175
query90	1940	124	115	115
query91	129	120	100	100
query92	72	70	70	70
query93	1691	1112	730	730
query94	633	255	214	214
query95	535	237	220	220
query96	786	556	260	260
query97	1034	1047	1015	1015
query98	166	139	129	129
query99	415	353	308	308
Total cold run time: 178383 ms
Total hot run time: 81635 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.11	0.11
query4	1.60	0.10	0.09
query5	0.18	0.16	0.16
query6	1.25	0.67	0.69
query7	0.04	0.01	0.01
query8	0.05	0.03	0.03
query9	0.28	0.22	0.21
query10	0.35	0.35	0.36
query11	0.17	0.11	0.12
query12	0.14	0.11	0.12
query13	0.29	0.30	0.30
query14	0.45	0.46	0.44
query15	0.36	0.34	0.35
query16	0.22	0.22	0.22
query17	0.69	0.69	0.70
query18	0.19	0.17	0.17
query19	1.24	1.19	1.13
query20	0.02	0.01	0.01
query21	15.42	0.16	0.11
query22	5.05	0.04	0.04
query23	16.19	0.26	0.10
query24	2.98	0.31	0.28
query25	0.10	0.04	0.03
query26	0.83	0.17	0.12
query27	0.03	0.03	0.03
query28	3.66	0.53	0.28
query29	12.41	3.17	2.56
query30	0.26	0.11	0.12
query31	2.76	0.37	0.17
query32	3.52	0.32	0.22
query33	1.50	1.38	1.53
query34	15.36	2.20	1.77
query35	1.76	1.74	1.77
query36	0.45	0.29	0.29
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.08
query41	0.08	0.02	0.02
query42	0.03	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.52 s
Total hot run time: 14.66 s

@Mryange

Mryange commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17578	3034	3007	3007
q2	2202	259	231	231
q3	10132	856	506	506
q4	4672	248	210	210
q5	7668	554	381	381
q6	140	115	94	94
q7	542	516	386	386
q8	9233	869	969	869
q9	3457	2434	2389	2389
q10	6506	867	717	717
q11	399	198	184	184
q12	608	264	193	193
q13	18135	1524	1148	1148
q14	154	152	143	143
q15	q16	438	399	374	374
q17	1362	945	817	817
q18	3108	2262	2278	2262
q19	1144	874	788	788
q20	394	281	198	198
q21	5316	1554	1848	1554
q22	331	269	223	223
Total cold run time: 93519 ms
Total hot run time: 16674 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3402	3328	3318	3318
q2	516	392	368	368
q3	2258	2403	2178	2178
q4	1185	1169	886	886
q5	2181	2135	2110	2110
q6	174	122	86	86
q7	1019	904	862	862
q8	1593	1401	1399	1399
q9	3118	3086	3110	3086
q10	1874	1810	1616	1616
q11	357	267	254	254
q12	450	428	338	338
q13	1490	1539	1160	1160
q14	165	173	162	162
q15	q16	390	399	358	358
q17	3586	3285	3331	3285
q18	4896	4437	4765	4437
q19	873	868	934	868
q20	1021	968	827	827
q21	3747	3052	3143	3052
q22	394	344	314	314
Total cold run time: 34689 ms
Total hot run time: 30964 ms

@hello-stephen

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

query5	4274	413	338	338
query6	392	140	127	127
query7	4940	428	231	231
query8	303	123	130	123
query9	8689	2859	2889	2859
query10	402	225	191	191
query11	5394	1059	932	932
query12	132	71	72	71
query13	1209	462	317	317
query14	6052	2186	2073	2073
query14_1	1959	1938	1934	1934
query15	179	123	112	112
query16	918	375	360	360
query17	797	457	385	385
query18	2332	326	238	238
query19	171	143	111	111
query20	72	69	69	69
query21	203	101	87	87
query22	5392	5348	5378	5348
query23	6575	6195	6089	6089
query23_1	6119	6095	6185	6095
query24	7312	1085	765	765
query24_1	786	771	785	771
query25	436	304	266	266
query26	1231	244	131	131
query27	2786	433	261	261
query28	4661	1501	1514	1501
query29	946	437	373	373
query30	263	158	125	125
query31	820	399	336	336
query32	132	78	80	78
query33	463	228	204	204
query34	999	831	473	473
query35	411	404	343	343
query36	567	566	534	534
query37	133	81	71	71
query38	996	852	813	813
query39	494	475	453	453
query39_1	462	479	459	459
query40	230	95	80	80
query41	60	56	53	53
query42	75	73	77	73
query43	240	237	213	213
query44	1030	552	552	552
query45	108	107	102	102
query46	766	870	528	528
query47	774	755	738	738
query48	316	303	231	231
query49	547	233	182	182
query50	760	261	195	195
query51	8091	7983	8004	7983
query52	66	66	60	60
query53	188	206	146	146
query54	222	190	182	182
query55	94	60	56	56
query56	188	201	170	170
query57	685	673	675	673
query58	207	164	167	164
query59	1220	1219	1066	1066
query60	250	195	168	168
query61	117	140	120	120
query62	398	200	176	176
query63	173	148	143	143
query64	2840	664	586	586
query65	1646	1547	1634	1547
query66	1868	268	215	215
query67	9840	9846	9731	9731
query68	2913	1262	781	781
query69	343	230	189	189
query70	667	608	642	608
query71	251	181	166	166
query72	2315	1759	1585	1585
query73	686	580	317	317
query74	1978	1210	1142	1142
query75	1191	1103	962	962
query76	2321	752	540	540
query77	245	257	216	216
query78	3944	3888	3290	3290
query79	2369	844	610	610
query80	1559	333	279	279
query81	486	154	137	137
query82	637	134	99	99
query83	277	209	194	194
query84	292	110	88	88
query85	786	358	290	290
query86	406	179	166	166
query87	1045	965	898	898
query88	2810	2084	2108	2084
query89	297	195	172	172
query90	1986	129	119	119
query91	130	119	99	99
query92	75	70	68	68
query93	1537	1168	738	738
query94	646	248	214	214
query95	520	316	221	221
query96	773	574	256	256
query97	1048	1068	1038	1038
query98	177	136	144	136
query99	433	341	301	301
Total cold run time: 178008 ms
Total hot run time: 82389 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.07	0.04	0.04
query3	0.25	0.11	0.11
query4	1.60	0.09	0.11
query5	0.17	0.16	0.17
query6	1.25	0.69	0.69
query7	0.03	0.01	0.00
query8	0.05	0.02	0.03
query9	0.29	0.21	0.21
query10	0.34	0.34	0.36
query11	0.17	0.11	0.11
query12	0.16	0.11	0.12
query13	0.31	0.32	0.30
query14	0.44	0.45	0.44
query15	0.36	0.35	0.35
query16	0.22	0.23	0.21
query17	0.68	0.66	0.69
query18	0.17	0.16	0.16
query19	1.16	1.19	1.11
query20	0.02	0.01	0.01
query21	15.46	0.16	0.12
query22	5.05	0.04	0.04
query23	16.20	0.25	0.10
query24	3.16	0.32	0.26
query25	0.10	0.05	0.03
query26	0.71	0.17	0.13
query27	0.05	0.03	0.03
query28	3.63	0.56	0.27
query29	12.44	3.14	2.54
query30	0.25	0.11	0.13
query31	2.76	0.39	0.17
query32	3.51	0.32	0.23
query33	1.59	1.39	1.52
query34	15.33	2.13	1.76
query35	1.74	1.71	1.69
query36	0.46	0.31	0.29
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.03	0.03
query40	0.12	0.08	0.07
query41	0.08	0.02	0.03
query42	0.04	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.59 s
Total hot run time: 14.52 s

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