Skip to content

[enhance](struct) Merge struct_element into element_at - #64027

Merged
csun5285 merged 4 commits into
apache:masterfrom
csun5285:fix/DORIS-26105-struct-subscript-coredump
Jun 8, 2026
Merged

csun5285 merged 4 commits into
apache:masterfrom
csun5285:fix/DORIS-26105-struct-subscript-coredump

Conversation

@csun5285

@csun5285 csun5285 commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Other databases / query engines do not have such a function, so we removed struct_element.

Struct fields should be accessed via element_at, the subscript operator s['f'] / s[idx], or the dot operator s.field.

doc: apache/doris-website#3898

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

@csun5285

csun5285 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 33.33% (1/3) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.58% (2/347) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17698	4016	4054	4016
q2	q3	10810	1365	793	793
q4	4687	484	339	339
q5	7576	939	603	603
q6	183	172	138	138
q7	756	853	651	651
q8	9380	1697	1619	1619
q9	5804	4552	4513	4513
q10	6689	1817	1528	1528
q11	440	269	252	252
q12	629	426	290	290
q13	18096	3286	2716	2716
q14	268	261	252	252
q15	q16	820	786	708	708
q17	1014	1002	942	942
q18	6947	5756	5591	5591
q19	1363	1412	1120	1120
q20	519	403	261	261
q21	6346	2794	2614	2614
q22	482	402	328	328
Total cold run time: 100507 ms
Total hot run time: 29274 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	5118	4838	4835	4835
q2	q3	4908	5383	4655	4655
q4	2127	2184	1404	1404
q5	4760	4920	4638	4638
q6	224	175	127	127
q7	1889	1770	1593	1593
q8	2393	2082	2104	2082
q9	7965	7366	7410	7366
q10	4765	4685	4252	4252
q11	531	384	354	354
q12	733	739	529	529
q13	3056	3358	2847	2847
q14	282	283	260	260
q15	q16	676	699	612	612
q17	1263	1260	1250	1250
q18	7107	6686	6780	6686
q19	1123	1100	1127	1100
q20	2218	2217	1957	1957
q21	5304	4603	4428	4428
q22	521	458	413	413
Total cold run time: 56963 ms
Total hot run time: 51388 ms

@hello-stephen

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

query5	4328	641	493	493
query6	454	203	183	183
query7	4877	562	312	312
query8	372	216	204	204
query9	8786	4042	4045	4042
query10	449	323	266	266
query11	5918	2361	2167	2167
query12	164	104	99	99
query13	1265	619	433	433
query14	6410	5438	5094	5094
query14_1	4462	4379	4397	4379
query15	206	196	180	180
query16	993	424	418	418
query17	1094	698	578	578
query18	2438	472	342	342
query19	200	182	143	143
query20	115	106	104	104
query21	227	137	116	116
query22	13641	13650	13485	13485
query23	17408	16575	16118	16118
query23_1	16188	16372	16312	16312
query24	7562	1798	1302	1302
query24_1	1330	1321	1362	1321
query25	568	448	388	388
query26	1316	339	172	172
query27	2618	575	326	326
query28	4458	1994	2000	1994
query29	1095	607	484	484
query30	312	242	202	202
query31	1136	1076	943	943
query32	120	60	58	58
query33	524	310	245	245
query34	1196	1131	642	642
query35	752	779	694	694
query36	1411	1391	1208	1208
query37	155	105	94	94
query38	3215	3201	3076	3076
query39	938	909	888	888
query39_1	901	931	885	885
query40	219	125	99	99
query41	65	62	64	62
query42	96	92	92	92
query43	321	330	272	272
query44	
query45	199	186	184	184
query46	1106	1243	776	776
query47	2332	2335	2233	2233
query48	401	438	305	305
query49	630	487	357	357
query50	998	365	264	264
query51	4265	4415	4358	4358
query52	88	88	78	78
query53	244	275	193	193
query54	271	241	203	203
query55	77	76	72	72
query56	259	225	225	225
query57	1416	1417	1294	1294
query58	258	219	217	217
query59	1610	1669	1448	1448
query60	299	262	245	245
query61	184	183	181	181
query62	717	669	590	590
query63	242	192	188	188
query64	2658	852	689	689
query65	
query66	1830	485	359	359
query67	29762	29697	29612	29612
query68	
query69	433	312	278	278
query70	988	999	934	934
query71	321	233	212	212
query72	3211	2920	2357	2357
query73	872	790	415	415
query74	5145	4938	4773	4773
query75	2729	2618	2247	2247
query76	2311	1222	778	778
query77	348	385	283	283
query78	12409	12531	11828	11828
query79	1491	1055	753	753
query80	588	485	390	390
query81	451	281	243	243
query82	869	159	124	124
query83	366	276	248	248
query84	262	141	117	117
query85	888	529	438	438
query86	385	301	277	277
query87	3385	3313	3225	3225
query88	3627	2731	2709	2709
query89	430	382	332	332
query90	1971	177	180	177
query91	176	169	141	141
query92	69	67	60	60
query93	1576	1412	851	851
query94	554	372	306	306
query95	680	382	364	364
query96	1085	864	358	358
query97	2703	2683	2587	2587
query98	217	207	203	203
query99	1177	1169	1026	1026
Total cold run time: 252222 ms
Total hot run time: 169828 ms

@csun5285
csun5285 force-pushed the fix/DORIS-26105-struct-subscript-coredump branch from cbd7023 to 5a06428 Compare June 3, 2026 10:58
Subscript access on a struct, s['field'], is parsed directly into an
element_at expression, but element_at only supported ARRAY and MAP and
aborted on a DCHECK in the BE (DORIS-26105). Rather than routing struct
field access through a separate struct_element function, make element_at
the single entry point for array/map/struct field access.

BE: FunctionArrayElement (element_at) now resolves a struct field by its
constant int/string index and the standalone struct_element function is
removed. The struct_element name is registered as a plain extra name on
the same implementation (not an alias: element_at is in the variadic set
because FunctionVariantElement shares the name, so an alias key would be
mangled to element_atStructString and fail to resolve), keeping any
persisted plan that still references struct_element resolvable.

FE: the StructElement node is removed and every struct field access form
(s['f'], s.f, element_at(s,'f'), struct_element(s,'f')) converges on
ElementAt, which absorbs the struct signature, legality check, int->name
normalization and the nested-column-pruning access path. struct_element
remains a user-facing SQL name bound to ElementAt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@csun5285
csun5285 force-pushed the fix/DORIS-26105-struct-subscript-coredump branch from 5a06428 to 51f5033 Compare June 3, 2026 11:53
@csun5285 csun5285 changed the title [fix](nereids) rewrite struct subscript s['f'] into struct_element [enhance](struct) Merge struct_element into element_at Jun 3, 2026
Projecting a struct field by its original mixed-case name (e.g. reading a
migrated Iceberg table whose schema keeps sName while Doris stores it as
sname, then querying sName) failed with an opaque error:
[INTERNAL_ERROR] function return type check failed ... real_return_type is nullptr.

Root cause: struct field names are canonically lower-cased by the FE (both
native DDL and the Iceberg schema read go through StructField.toLowerCase),
but a query may reference a field with different casing. The FE matches the
field case-insensitively and forwards the original-case name to the BE, while
DataTypeStruct::try_get_position_by_name compared case-sensitively, so the
field was not found, get_return_type returned nullptr and build() reported
the opaque internal error.

Fix:
- DataTypeStruct::try_get_position_by_name / get_position_by_name match the
  field name case-insensitively (iequal).
- element_at's struct return-type path throws the concrete "field not found /
  index out of bound" error instead of returning nullptr, so an unresolvable
  field surfaces a clear message rather than an internal error.

DORIS-26117

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@csun5285

csun5285 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

csun5285 added a commit to csun5285/doris-website that referenced this pull request Jun 3, 2026
Reflect apache/doris#64027 latest changes: struct_element is now subsumed
by element_at (kept as a backward-compatible alias), struct field names are
matched case-insensitively, document the dot operator s.field access form,
and update the non-constant index error message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17696	4032	3997	3997
q2	q3	10743	1355	807	807
q4	4713	472	353	353
q5	7811	848	589	589
q6	202	172	138	138
q7	825	835	651	651
q8	10281	1709	1587	1587
q9	7299	4524	4508	4508
q10	6809	1816	1552	1552
q11	433	276	244	244
q12	637	423	287	287
q13	18153	3428	2791	2791
q14	274	255	245	245
q15	q16	817	773	708	708
q17	921	966	957	957
q18	6819	5725	5577	5577
q19	1176	1288	1028	1028
q20	504	394	256	256
q21	5975	2750	2537	2537
q22	467	373	315	315
Total cold run time: 102555 ms
Total hot run time: 29127 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4853	4764	4791	4764
q2	q3	5100	5203	4672	4672
q4	2096	2189	1403	1403
q5	5017	4663	4657	4657
q6	227	182	127	127
q7	1957	1825	1555	1555
q8	2341	1945	1938	1938
q9	7455	7406	7438	7406
q10	4739	4666	4208	4208
q11	532	390	360	360
q12	735	822	590	590
q13	3022	3359	2818	2818
q14	276	279	271	271
q15	q16	669	700	624	624
q17	1292	1268	1239	1239
q18	7184	6644	6931	6644
q19	1132	1114	1127	1114
q20	2209	2222	1944	1944
q21	5246	4559	4555	4555
q22	514	436	412	412
Total cold run time: 56596 ms
Total hot run time: 51301 ms

@hello-stephen

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

query5	4332	640	505	505
query6	440	206	189	189
query7	4807	582	294	294
query8	366	214	213	213
query9	8753	3995	4023	3995
query10	440	311	260	260
query11	5921	2318	2197	2197
query12	151	101	98	98
query13	1256	607	433	433
query14	6406	5370	5081	5081
query14_1	4418	4401	4386	4386
query15	211	205	178	178
query16	992	451	431	431
query17	1134	721	592	592
query18	2513	480	348	348
query19	215	187	153	153
query20	116	110	109	109
query21	216	135	118	118
query22	13663	13644	13415	13415
query23	17307	16551	16192	16192
query23_1	16296	16223	16365	16223
query24	7537	1783	1327	1327
query24_1	1269	1350	1294	1294
query25	543	444	386	386
query26	1313	320	167	167
query27	2664	521	339	339
query28	4465	2026	2040	2026
query29	1061	606	493	493
query30	312	234	201	201
query31	1139	1081	947	947
query32	113	60	57	57
query33	523	324	254	254
query34	1163	1187	670	670
query35	762	798	674	674
query36	1408	1369	1236	1236
query37	148	102	90	90
query38	3200	3154	3046	3046
query39	929	923	906	906
query39_1	886	884	889	884
query40	222	125	102	102
query41	66	62	63	62
query42	94	93	95	93
query43	321	323	277	277
query44	
query45	194	183	181	181
query46	1099	1175	735	735
query47	2324	2417	2183	2183
query48	415	390	287	287
query49	653	475	357	357
query50	1036	345	247	247
query51	4316	4374	4260	4260
query52	88	86	78	78
query53	233	267	191	191
query54	277	216	199	199
query55	77	73	68	68
query56	226	234	217	217
query57	1450	1400	1308	1308
query58	240	217	209	209
query59	1579	1619	1439	1439
query60	296	247	230	230
query61	159	158	161	158
query62	692	664	593	593
query63	230	183	183	183
query64	2569	773	635	635
query65	
query66	1777	479	348	348
query67	29940	29564	29449	29449
query68	
query69	418	309	258	258
query70	991	973	949	949
query71	290	232	229	229
query72	3023	2706	2385	2385
query73	861	711	425	425
query74	5159	4957	4798	4798
query75	2664	2574	2242	2242
query76	2320	1138	759	759
query77	354	376	289	289
query78	12385	12366	11893	11893
query79	1412	1060	787	787
query80	579	483	392	392
query81	454	285	251	251
query82	581	152	122	122
query83	361	275	246	246
query84	267	147	113	113
query85	888	555	470	470
query86	363	291	275	275
query87	3376	3363	3162	3162
query88	3611	2727	2710	2710
query89	430	382	331	331
query90	1911	181	185	181
query91	181	166	138	138
query92	63	62	58	58
query93	1501	1512	847	847
query94	555	353	305	305
query95	682	385	434	385
query96	1152	855	361	361
query97	2709	2712	2593	2593
query98	211	203	214	203
query99	1171	1170	1024	1024
Total cold run time: 251303 ms
Total hot run time: 169412 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 78.22% (79/101) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.95% (27497/38217)
Line Coverage 55.45% (294164/530534)
Region Coverage 52.01% (244473/470064)
Branch Coverage 53.26% (105885/198802)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 58.33% (28/48) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 78.22% (79/101) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.95% (27497/38217)
Line Coverage 55.45% (294164/530534)
Region Coverage 52.01% (244473/470064)
Branch Coverage 53.26% (105885/198802)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 11.24% (28/249) 🎉
Increment coverage report
Complete coverage report

@csun5285

csun5285 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.00% (24/48) 🎉
Increment coverage report
Complete coverage report

…tainer

The struct_element->element_at merge kept PropagateNullLiteral on
ElementAt (inherited from the old StructElement). FoldConstantRuleOnFE
then folds any element_at whose argument is a null literal to a NULL
literal. That is correct when the container is null (element_at(NULL, i))
but wrong for a map: a map may contain a null key, so element_at(map,
NULL) must be evaluated by the BE to look up that key, otherwise m[null]
always returns NULL.

Fix: keep PropagateNullLiteral (so element_at(NULL, i) and a null
array/struct index still fold to NULL, e.g. the union push-down in
PruneNestedColumnTest), but override foldable() to return false for the
single problematic shape element_at(map, <null literal>), so it is left
to the BE instead of being folded away.

Fixes the regression in map_agg and test_map_load_and_function where
m[NULL] returned NULL instead of the null-key value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@csun5285
csun5285 force-pushed the fix/DORIS-26105-struct-subscript-coredump branch from 2138066 to dd81b69 Compare June 4, 2026 12:52
@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17668	4027	4051	4027
q2	q3	10801	1485	841	841
q4	4699	490	354	354
q5	7586	924	603	603
q6	187	175	144	144
q7	811	867	655	655
q8	9399	1612	1608	1608
q9	5849	4532	4516	4516
q10	6758	1813	1518	1518
q11	440	282	259	259
q12	633	422	292	292
q13	18188	3366	2754	2754
q14	270	265	244	244
q15	q16	834	765	712	712
q17	1018	990	995	990
q18	6866	5615	5482	5482
q19	1322	1287	1089	1089
q20	561	406	267	267
q21	6286	2909	2607	2607
q22	478	383	331	331
Total cold run time: 100654 ms
Total hot run time: 29293 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	5209	4812	4814	4812
q2	q3	4911	5289	4703	4703
q4	2145	2221	1404	1404
q5	4875	4965	4682	4682
q6	236	178	127	127
q7	2045	2051	1521	1521
q8	2449	2154	2099	2099
q9	7997	7798	7437	7437
q10	4770	4684	4236	4236
q11	538	400	360	360
q12	743	739	538	538
q13	3054	3432	2766	2766
q14	281	291	264	264
q15	q16	672	700	620	620
q17	1293	1261	1259	1259
q18	7183	6690	6844	6690
q19	1134	1126	1075	1075
q20	2210	2209	1949	1949
q21	5324	4586	4469	4469
q22	530	476	401	401
Total cold run time: 57599 ms
Total hot run time: 51412 ms

@hello-stephen

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

query5	4340	628	482	482
query6	434	204	181	181
query7	4852	590	316	316
query8	360	221	206	206
query9	8786	4041	4050	4041
query10	457	315	264	264
query11	5797	2355	2240	2240
query12	153	101	99	99
query13	1245	574	424	424
query14	6375	5426	5145	5145
query14_1	4450	4456	4430	4430
query15	207	193	170	170
query16	979	440	439	439
query17	912	685	570	570
query18	2435	476	341	341
query19	195	180	145	145
query20	114	107	105	105
query21	219	141	124	124
query22	13631	13612	13918	13612
query23	17402	16504	16256	16256
query23_1	16200	16305	16232	16232
query24	7517	1791	1329	1329
query24_1	1302	1312	1345	1312
query25	554	445	390	390
query26	1328	305	171	171
query27	2701	561	345	345
query28	4455	2050	2020	2020
query29	1053	612	484	484
query30	309	236	197	197
query31	1132	1071	960	960
query32	118	61	57	57
query33	511	310	255	255
query34	1177	1144	633	633
query35	773	785	686	686
query36	1403	1397	1287	1287
query37	152	106	94	94
query38	3238	3164	3075	3075
query39	938	951	893	893
query39_1	871	863	873	863
query40	223	128	102	102
query41	65	62	64	62
query42	98	100	93	93
query43	322	325	284	284
query44	
query45	202	193	178	178
query46	1092	1253	770	770
query47	2340	2338	2217	2217
query48	394	407	304	304
query49	667	466	362	362
query50	1027	361	259	259
query51	4395	4416	4212	4212
query52	86	89	78	78
query53	238	280	201	201
query54	288	214	219	214
query55	78	77	71	71
query56	247	221	215	215
query57	1411	1415	1299	1299
query58	243	219	206	206
query59	1583	1677	1440	1440
query60	290	256	230	230
query61	164	158	151	151
query62	700	665	594	594
query63	235	190	187	187
query64	2556	808	621	621
query65	
query66	1807	466	346	346
query67	29819	29649	29652	29649
query68	
query69	441	324	279	279
query70	1012	979	970	970
query71	318	231	227	227
query72	3135	2869	2566	2566
query73	849	758	433	433
query74	5166	4990	4773	4773
query75	2685	2619	2289	2289
query76	2324	1208	846	846
query77	373	377	313	313
query78	12410	12577	11936	11936
query79	1479	1053	761	761
query80	1162	495	402	402
query81	524	286	240	240
query82	886	159	125	125
query83	364	284	253	253
query84	369	146	111	111
query85	971	528	430	430
query86	432	293	309	293
query87	3406	3322	3180	3180
query88	3681	2777	2750	2750
query89	441	386	331	331
query90	1852	187	181	181
query91	179	169	140	140
query92	74	59	59	59
query93	1587	1573	808	808
query94	636	372	309	309
query95	701	472	356	356
query96	1049	781	337	337
query97	2679	2699	2578	2578
query98	209	206	209	206
query99	1182	1196	1035	1035
Total cold run time: 252607 ms
Total hot run time: 170738 ms

@csun5285

csun5285 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 64.36% (65/101) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.92% (21047/39035)
Line Coverage 37.60% (200188/532474)
Region Coverage 33.68% (156979/466099)
Branch Coverage 34.64% (68690/198312)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.00% (83/100) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.85% (28252/38255)
Line Coverage 57.89% (307551/531307)
Region Coverage 54.67% (257430/470852)
Branch Coverage 56.11% (111776/199211)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 60.78% (31/51) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.00% (83/100) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.84% (28249/38255)
Line Coverage 57.89% (307558/531307)
Region Coverage 54.73% (257714/470852)
Branch Coverage 56.11% (111772/199211)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 60.78% (31/51) 🎉
Increment coverage report
Complete coverage report

csun5285 added a commit to csun5285/doris-website that referenced this pull request Jun 8, 2026
Per apache/doris#64027, STRUCT_ELEMENT is removed since 4.1.3 and subsumed
by ELEMENT_AT. Add a caution notice on the STRUCT_ELEMENT page (EN/ZH)
pointing users to ELEMENT_AT and the equivalent subscript/dot syntax.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
csun5285 added a commit to csun5285/doris-website that referenced this pull request Jun 8, 2026
STRUCT_ELEMENT is removed since 4.1.3 (apache/doris#64027). Rewrite the
"Element Access" section to lead with ELEMENT_AT / subscript / dot syntax,
add a caution notice, and switch the nested-struct example to the dot
operator (verified by the test_dereference regression test). EN + ZH.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
yiguolei pushed a commit to apache/doris-website that referenced this pull request Jun 8, 2026
…T_ELEMENT (#3898)

Update the STRUCT field-access docs to match apache/doris#64027, which
merges
`struct_element` into `element_at`. `STRUCT_ELEMENT` is removed since
version
4.1.3; struct fields are now accessed via `ELEMENT_AT`, the subscript
operator,
  or the dot operator — all equivalent:

  - `ELEMENT_AT(s, k)` / `ELEMENT_AT(s, 'field_name')`
  - `s[k]` / `s['field_name']`
  - `s.field_name` (and nested `s.a.b`, for a STRUCT column)

## Versions 

- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1 or older (not covered by version/language sync gate)

## Languages

- [x] Chinese
- [x] English
- [ ] Japanese candidate translation needed

## Docs Checklist

- [ ] Checked by AI
- [ ] Test Cases Built
- [ ] Updated required version and language counterparts, or explained
why not
- [ ] If only one language changed, confirmed whether source/translation
counterparts need sync

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@morrySnow

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.

Automated review summary:

I did not find additional distinct inline issues beyond the existing review threads, so I am not duplicating those comments. The current PR still appears to contain the two already-raised blockers:

  • struct_element is still removed as a FE/BE public function name, which is a user-visible incompatible change for existing SQL, views, clients, and persisted references.
  • Struct integer index resolution in FE still uses truncated int values (IntegerLikeLiteral#getIntValue() / equivalent int conversion), so indexes wider than Integer.MAX_VALUE can be analyzed with the wrong field before BE rejects the original value.

Critical checkpoint conclusions:

  • Goal/test: The PR aims to route struct access through element_at and updates tests for common struct access, NULL struct rows, subscript syntax, NCP paths, and BE field lookup. Existing tests cover the intended happy paths, but the wide-index negative regression requested in the existing thread is still missing.
  • Scope/focus: The implementation is mostly focused on the struct_element to element_at merge, with broad test/query rewrites caused by removing the old name.
  • Concurrency/lifecycle: No new shared mutable state, background threads, lock ordering, or special lifecycle/static-initialization concerns were found in the reviewed function/rule paths.
  • Configuration/compatibility: No config items are added. There is a compatibility concern because the public struct_element name is removed; this is already covered by an existing inline thread.
  • Parallel paths: FE and BE both add struct handling to element_at; variant/array/map paths are preserved. The removed struct_element alias remains the main parallel-path/compatibility gap.
  • Conditional checks/error handling: BE now returns concrete field-not-found/out-of-bound errors instead of opaque return-type failure, which is good. The FE wide integer bounds check remains problematic as already reported.
  • Test coverage/results: Regression and BE unit tests were added/updated for normal struct access and case-insensitive BE field lookup. Negative coverage for out-of-range wide integer struct indexes and compatibility coverage for struct_element are still absent.
  • Observability: No new long-running or distributed operation is introduced; existing errors include the function/index/name context and are sufficient for this path.
  • Transaction/persistence/data writes: Not applicable; no transaction, persisted metadata, storage format, or data write path changes were found.
  • FE/BE protocol/type consistency: FE and BE agree for ordinary struct field resolution, including nullable result shape. The already-reported wide-index truncation can still make FE infer a different field type than BE validates.
  • Security model: Auth/TLS-sensitive areas are not part of this PR's actual file list from gh pr view; no additional security finding was identified.
  • User focus: No additional user-provided review focus was supplied.

Please resolve the existing blocker threads before merge.

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

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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

@csun5285
csun5285 merged commit 2867e9c into apache:master Jun 8, 2026
18 of 20 checks passed
eldenmoon pushed a commit that referenced this pull request Jun 8, 2026
…ion suites (#64204)

PR #64027 removed the struct_element SQL function (merged into
element_at), but PR #63736 (merged just before it) added the
topn_expr_pullup and topn_lazy_nested_column_pruning suites that still
call struct_element(...). Because #64027 was prepared before #63736
landed, its cleanup never touched these new files, leaving regression
suites that call a removed function.


### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] Regression test
    - [ ] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
csun5285 added a commit to csun5285/doris that referenced this pull request Jun 9, 2026
apache#64027 merged struct_element into element_at and removed the
struct_element function entirely. Users upgrading from an older
version whose SQL / views still reference struct_element then fail
with "function not found".

Re-register struct_element as an alias of element_at on both sides:
- FE: register the name struct_element on the ElementAt class, so it
  resolves to ElementAt (whose name is element_at) and reuses all of
  element_at's struct-handling logic; the function name sent to BE is
  always element_at.
- BE: add a defensive register_alias so a struct_element name also
  resolves to the element_at implementation.

Add regression cases asserting struct_element over a struct returns
exactly the same results as element_at.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
csun5285 added a commit that referenced this pull request Jun 9, 2026
#64027 merged struct_element into element_at and removed the
struct_element function entirely. Users upgrading from an older version
whose SQL / views still reference struct_element then fail with
"function not found".
github-actions Bot pushed a commit that referenced this pull request Jun 9, 2026
#64027 merged struct_element into element_at and removed the
struct_element function entirely. Users upgrading from an older version
whose SQL / views still reference struct_element then fail with
"function not found".
@yiguolei yiguolei mentioned this pull request Jun 14, 2026
jacktengg added a commit that referenced this pull request Nov 23, 2026
### Background

FE checks and folds constant function arguments. BE evaluates row
arguments and resolves STRUCT ordinals for execution.

### What problem does this PR solve?

Issue Number: None
Related PR: #64027 (retained STRUCT ordinal narrowing)
PR Type: Bugfix

Problem Summary:

Some function arguments lose high bits, change sign, or overflow before
validation. For example, element_at(struct(7), 4294967297) returns 7
instead of an error. This change extracts six fixes and their tests.
Valid boundary inputs return correct results; invalid arguments report
errors.

### Details

- **Change map:** 173 production lines: STRUCT lookup and pruning 68,
substring counts 6, array lengths 14, bitmap elements 54, funnel windows
16, ngram sizes 7, and the shared range helper 8. Tests change 390
lines; generated results add 23. No documentation or protocol changes.
- **Frequency:** Always for the reported boundary inputs. BE substring
behavior can depend on compiler handling of signed overflow.
- **Root cause:** STRUCT and ngram narrow integers before checks.
SUBSTRING_INDEX negates INT_MIN. ARRAY_SLICE adds length before
clamping. Bitmap functions convert negative elements to unsigned values.
An empty funnel event list bypasses window validation.
- **Why existing tests missed it:** StructOrdinal coverage was absent.
Existing STRUCT, StringArithmetic, bitmap and funnel UTs use ordinary
values. The closest SQL suites omit wide aliases and signed minima;
test_ngram_search_gram_num covers ordinary negative sizes but not values
beyond INT or BIGINT.
- **Fix:** Check full-width values before conversion. Widen before
negation or absolute value. Clamp length before addition. Reject
negative elements and windows before execution shortcuts.
- **Other paths and branches:** Cover STRUCT normalization and pruning,
both bitmap functions, FE constants, and BE rows. ARRAY_SLICE INT64_MIN
positions remain outside this extraction. Source commits are
62eaf86, 9d58004, and d73c2e1. Release-branch applicability
was not rechecked.
- **Behavior change:** Invalid ordinals, bitmap elements, funnel
windows, and ngram sizes report errors. Extreme valid substring counts
and array lengths return correct results. No configuration or
storage-format change.

### Testing

Local checks on master 0a6b84b plus this patch:

- build.sh --be --fe: passed with ASAN; FE Checkstyle passed.
- run-fe-ut.sh: 109 tests passed across five selected classes.
- run-be-ut.sh: 35 tests passed, including all five new BE cases.
- run-regression-test.sh: generated two new result files, checked their
values, then passed test_struct_field_ordinal,
test_selected_function_parameters, and test_ngram_search_gram_num. No
skips.
- C++ formatting, header hygiene, and clang-tidy on eight changed files
passed.

Supplied reports reproduce the old results on the same master baseline.
That baseline was not rebuilt during this extraction. Runtime checks
used the candidate artifacts from this worktree.

### Release note

Fix incorrect results and missing argument errors in STRUCT access,
SUBSTRING_INDEX, ARRAY_SLICE, BITMAP_CONTAINS, BITMAP_REMOVE,
WINDOW_FUNNEL_V2, and NGRAM_SEARCH.

### Check List (For Author)

- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Ready

### AI Disclosure

- Tool: Codex (GPT-6 family).
- Generated: Selected patch, scoped tests, review notes, and this
description.
- Human review: The author has not supplied a human-review statement.

<!-- Recommended: develop the change with the develop-with-evidence
skill and write this description with the doris-pr-description skill,
both from https://github.com/apache/doris-skills (the doris-skills
submodule of this repository). -->

### Background

<!-- How the feature or module this PR touches works today, in two to
four plain sentences, for a reviewer who doesn't know it. Link the user
doc if there is one. Leave the problem and the fix to Problem Summary.
-->

### What problem does this PR solve?

<!-- Issue Number: "close #N" if this PR resolves the issue, "#N" if it
only relates to it, "None" if there is none. A Feature needs an issue.
-->
<!-- Related PR: "#N (relation)" for each PR a reviewer should know
about, such as "#123 (introduced the bug)", separated by commas. Write
"None" if no related PR is known. -->
<!-- PR Type: Bugfix, Performance, Feature, Enhancement, Refactor, Test,
Build/CI/Chore, Revert, Release/Dependency, or Other. -->

Issue Number:
Related PR:
PR Type:

Problem Summary:

<!-- Two to five sentences: the problem or need and who is affected; the
approach in one sentence; when the diff is larger than that suggests,
what else it had to handle, or that most of it is tests; and what
existing users see after an upgrade. -->

### Details

<!--
For a diff of more than about 300 changed lines, start with "- **Change
map:**": how many lines are production code, tests, generated files, and
docs, then the code in parts, each with the problem it handles and its
size.
Then answer each field of your PR type on its own line, as "- **Field:**
answer", in this order:
Bugfix: Frequency, Root cause, Why existing tests missed it, Fix, Other
paths and branches
Performance: Why it was slow, Optimization, Results, Applicability and
cost
  Feature: Scope, Design, Usage, Default behavior, Compatibility
Enhancement: Before and after, Configs and defaults, Impact on existing
users
Refactor: Moves vs. logic changes, Behavior change, Compatibility,
Performance impact, Rollback
Test, adding tests: Scenarios, What existing tests miss, Fails when
broken
  Test, fixing a test: Failure, Cause, Stability evidence
Build/CI/Chore: Affected, Developer and release impact, License and
third-party, Rollback
  Revert: Why not fix forward, Original author notified, Follow-up
Release/Dependency: Versions, Upstream changes, Compatibility, Rollback
  Other: Why Other
"None" is a valid answer when it is true. Don't restate the diff.
-->

### Testing

<!-- The tests, suites, or commands that ran, what each shows, and where
it ran (locally or in CI). For a fix, the test that fails before it and
passes after. -->

### Notes for Reviewers

<!-- Optional; delete this section if there is nothing to say. Why each
non-obvious edit was made, what you are unsure about, and where to start
reading if Details has no Change map. -->

### Release note

<!-- One paragraph on what users will notice, or None. -->

### Check List (For Author)

<!-- Behavior changed: "No", or "Yes (see Details)" with a Behavior
change field in Details. -->
<!-- Does this need documentation: "No", or "Yes" with the
apache/doris-website PR or the plan. -->
<!-- Pre-submission status: "Ready"; "Partially verified: " and what is
not verified; or "Not ready: " and why, for a Draft PR. -->

- Behavior changed:
- Does this need documentation:
- Pre-submission status:

### AI Disclosure

<!-- Tool: the agent and model, or None. Generated: the parts it wrote
(code, tests, this description), or None. Human review: what you
reviewed of the generated parts, or "Not applicable" without AI tools.
You may add "- Prompts:" to summarize how you directed the agent. -->

- Tool:
- Generated:
- Human review:
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/4.1.2-merged kind/behavior-changed lfs-detected! Warning Label for use when LFS is detected in the commits of a Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants