Skip to content

[fix](be) Throw on invalid function return type inference#64050

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fixreturntypethrow
Open

[fix](be) Throw on invalid function return type inference#64050
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fixreturntypethrow

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented Jun 3, 2026

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: Some BE function return type inference paths could return nullptr after detecting an invalid return type or unsupported implementation. For struct_element, an invalid field name or index produced a Status but get_return_type_impl returned nullptr, which let the outer return-type check report a generic nullptr mismatch and masked the original error. This change makes these paths throw exceptions directly and keeps the base builder from propagating nullptr return types.

Release note

None

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

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: Some BE function return type inference paths could return nullptr after detecting an invalid return type or unsupported implementation. For struct_element, an invalid field name or index produced a Status but get_return_type_impl returned nullptr, which let the outer return-type check report a generic nullptr mismatch and masked the original error. This change makes these paths throw exceptions directly and keeps the base builder from propagating nullptr return types.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - sh run-be-ut.sh --run --filter="FunctionStructElementTest*"
- Behavior changed: No
- 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
Copy link
Copy Markdown
Contributor Author

Mryange commented Jun 3, 2026

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Review conclusion: no blocking issues found.

Critical checkpoint conclusions:

  • Goal and tests: The PR makes invalid/unsupported BE function return-type inference fail with explicit exceptions instead of propagating nullptr; the changed code accomplishes that for the touched paths, and the added BE unit test covers invalid struct_element field lookup.
  • Scope and clarity: The change is small and focused on return-type inference error handling.
  • Concurrency: No new concurrency or shared mutable lifecycle behavior is introduced.
  • Lifecycle/static initialization: No new static/global initialization dependencies are introduced.
  • Configuration/compatibility: No new configs, storage formats, or FE-BE protocol fields are introduced.
  • Parallel paths: CAST and struct_element touched paths are consistent with the existing builder exception model; no additional required parallel-path changes were identified in this PR scope.
  • Error handling: New exceptions are in vectorized function preparation/type-resolution paths and are covered by existing VExprContext exception-to-Status boundaries.
  • Tests: Unit coverage was added for the struct_element invalid-field case. I did not run tests in this review runner.
  • Observability/performance: No new observability requirement or meaningful performance regression was identified.

User focus points: No additional user-provided review focus was specified.

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented Jun 3, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 12.50% (1/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.11% (27540/38191)
Line Coverage 55.52% (294517/530477)
Region Coverage 52.30% (245917/470207)
Branch Coverage 53.43% (106208/198764)

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 29599 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a9653331a8376f5108c8d1812a1eb7a5d85ac7db, 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	17684	4021	3992	3992
q2	q3	10816	1458	838	838
q4	4690	489	349	349
q5	7567	889	587	587
q6	188	179	139	139
q7	788	896	653	653
q8	9369	1621	1586	1586
q9	5846	4554	4477	4477
q10	6817	1830	1524	1524
q11	436	275	250	250
q12	626	436	305	305
q13	18135	3540	2844	2844
q14	262	262	242	242
q15	q16	829	775	709	709
q17	1003	966	1037	966
q18	7084	5883	5698	5698
q19	1562	1320	1154	1154
q20	515	410	264	264
q21	6417	2892	2697	2697
q22	460	376	325	325
Total cold run time: 101094 ms
Total hot run time: 29599 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	5227	4857	4811	4811
q2	q3	5018	5264	4714	4714
q4	2225	2222	1404	1404
q5	4850	4771	4665	4665
q6	231	181	128	128
q7	1979	1754	1605	1605
q8	2498	2115	2187	2115
q9	7972	7538	7450	7450
q10	4787	4707	4240	4240
q11	538	415	363	363
q12	743	747	527	527
q13	2951	3442	2856	2856
q14	275	281	254	254
q15	q16	683	696	626	626
q17	1318	1304	1282	1282
q18	7306	6971	6926	6926
q19	1150	1163	1094	1094
q20	2230	2223	1935	1935
q21	5430	4647	4538	4538
q22	548	486	433	433
Total cold run time: 57959 ms
Total hot run time: 51966 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

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

query5	4310	639	476	476
query6	447	198	188	188
query7	4914	563	309	309
query8	380	227	214	214
query9	8805	4094	4162	4094
query10	467	311	269	269
query11	5982	2342	2205	2205
query12	161	104	102	102
query13	1302	617	446	446
query14	6400	5423	5080	5080
query14_1	4434	4442	4394	4394
query15	207	200	178	178
query16	1014	460	440	440
query17	1137	761	576	576
query18	2603	464	344	344
query19	192	178	139	139
query20	111	108	114	108
query21	216	139	112	112
query22	13670	13522	13309	13309
query23	17522	16606	16203	16203
query23_1	16301	16233	16271	16233
query24	7567	1765	1275	1275
query24_1	1303	1321	1342	1321
query25	549	444	382	382
query26	1309	313	170	170
query27	2676	552	324	324
query28	4474	2002	2032	2002
query29	1075	614	497	497
query30	312	236	197	197
query31	1110	1104	956	956
query32	113	60	58	58
query33	537	323	247	247
query34	1191	1180	652	652
query35	759	783	677	677
query36	1413	1437	1258	1258
query37	157	102	92	92
query38	3199	3153	3017	3017
query39	941	931	910	910
query39_1	877	889	875	875
query40	213	126	102	102
query41	65	64	64	64
query42	100	96	93	93
query43	319	320	290	290
query44	
query45	197	191	183	183
query46	1137	1228	767	767
query47	2358	2339	2302	2302
query48	400	419	307	307
query49	648	484	365	365
query50	1024	362	262	262
query51	4356	4369	4267	4267
query52	91	91	79	79
query53	251	278	191	191
query54	286	244	212	212
query55	80	78	77	77
query56	264	262	239	239
query57	1446	1390	1330	1330
query58	258	225	219	219
query59	1594	1721	1443	1443
query60	299	260	246	246
query61	189	202	183	183
query62	704	674	587	587
query63	238	187	188	187
query64	2626	820	676	676
query65	
query66	1849	487	391	391
query67	29781	29819	29580	29580
query68	
query69	431	288	270	270
query70	1014	931	948	931
query71	308	222	214	214
query72	2957	2712	2412	2412
query73	868	754	418	418
query74	5151	4948	4756	4756
query75	2693	2593	2226	2226
query76	2302	1187	781	781
query77	357	392	288	288
query78	12385	12576	11889	11889
query79	1465	1093	813	813
query80	1301	474	394	394
query81	504	281	243	243
query82	582	163	124	124
query83	351	276	246	246
query84	264	139	113	113
query85	923	542	439	439
query86	411	309	288	288
query87	3409	3322	3163	3163
query88	3653	2751	2726	2726
query89	441	382	329	329
query90	1795	182	182	182
query91	177	169	141	141
query92	64	61	59	59
query93	1522	1610	965	965
query94	695	352	322	322
query95	672	391	354	354
query96	1094	766	346	346
query97	2679	2680	2534	2534
query98	209	210	202	202
query99	1166	1173	1032	1032
Total cold run time: 253017 ms
Total hot run time: 170109 ms

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented Jun 5, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 12.50% (1/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.77% (21056/39158)
Line Coverage 37.47% (200179/534264)
Region Coverage 33.50% (156987/468640)
Branch Coverage 34.54% (68686/198884)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 12.50% (1/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.92% (27512/38251)
Line Coverage 55.35% (293812/530779)
Region Coverage 52.07% (244795/470158)
Branch Coverage 53.21% (105909/199037)

1 similar comment
@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 12.50% (1/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.92% (27512/38251)
Line Coverage 55.35% (293812/530779)
Region Coverage 52.07% (244795/470158)
Branch Coverage 53.21% (105909/199037)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 12.50% (1/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.75% (28213/38253)
Line Coverage 57.74% (306728/531216)
Region Coverage 54.49% (256577/470844)
Branch Coverage 55.91% (111351/199167)

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 29555 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a9653331a8376f5108c8d1812a1eb7a5d85ac7db, 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	17622	4061	3997	3997
q2	q3	10832	1416	855	855
q4	4686	487	344	344
q5	7555	905	599	599
q6	183	176	137	137
q7	788	878	647	647
q8	9387	1702	1634	1634
q9	5760	4583	4551	4551
q10	6808	1844	1559	1559
q11	434	297	264	264
q12	637	440	321	321
q13	18126	3430	2837	2837
q14	268	257	239	239
q15	q16	822	788	721	721
q17	1003	908	931	908
q18	7107	5650	5601	5601
q19	1369	1265	1084	1084
q20	513	408	264	264
q21	6249	2924	2674	2674
q22	465	387	319	319
Total cold run time: 100614 ms
Total hot run time: 29555 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	5088	4693	4780	4693
q2	q3	4840	5358	4737	4737
q4	2149	2232	1416	1416
q5	4791	4968	4681	4681
q6	236	174	127	127
q7	1843	1686	1591	1591
q8	2454	2117	2092	2092
q9	7852	7811	7404	7404
q10	4806	4667	4213	4213
q11	525	381	349	349
q12	736	741	584	584
q13	3034	3330	2812	2812
q14	276	276	252	252
q15	q16	676	701	607	607
q17	1289	1263	1266	1263
q18	7330	6980	6886	6886
q19	1133	1092	1129	1092
q20	2209	2196	1932	1932
q21	5294	4588	4482	4482
q22	544	453	425	425
Total cold run time: 57105 ms
Total hot run time: 51638 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

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

query5	4332	634	483	483
query6	447	195	179	179
query7	4821	564	317	317
query8	377	220	197	197
query9	8772	4029	4045	4029
query10	457	312	262	262
query11	5843	2338	2215	2215
query12	164	105	102	102
query13	1271	641	449	449
query14	6436	5398	5085	5085
query14_1	4420	4391	4372	4372
query15	205	198	178	178
query16	1028	473	471	471
query17	1133	724	611	611
query18	2479	487	375	375
query19	210	192	151	151
query20	119	111	108	108
query21	222	139	120	120
query22	13680	13625	13319	13319
query23	17432	16511	16219	16219
query23_1	16234	16298	16359	16298
query24	7456	1800	1344	1344
query24_1	1315	1330	1308	1308
query25	547	454	385	385
query26	1306	316	165	165
query27	2655	542	348	348
query28	4447	2020	1982	1982
query29	1071	597	475	475
query30	308	234	197	197
query31	1116	1071	959	959
query32	104	61	59	59
query33	525	320	247	247
query34	1205	1133	650	650
query35	753	802	669	669
query36	1408	1407	1271	1271
query37	151	106	93	93
query38	3221	3138	3038	3038
query39	918	923	890	890
query39_1	881	888	890	888
query40	220	124	99	99
query41	68	65	65	65
query42	95	94	94	94
query43	322	321	282	282
query44	
query45	197	187	183	183
query46	1102	1214	739	739
query47	2418	2416	2217	2217
query48	424	422	304	304
query49	625	456	357	357
query50	983	356	261	261
query51	4320	4375	4259	4259
query52	95	89	76	76
query53	242	271	194	194
query54	291	233	220	220
query55	79	74	70	70
query56	237	230	218	218
query57	1429	1413	1355	1355
query58	252	225	213	213
query59	1579	1646	1467	1467
query60	289	252	235	235
query61	162	194	157	157
query62	700	653	593	593
query63	230	186	184	184
query64	2559	795	658	658
query65	
query66	1773	463	340	340
query67	29876	29771	29606	29606
query68	
query69	447	306	273	273
query70	999	970	941	941
query71	293	213	215	213
query72	2984	2720	2466	2466
query73	860	767	411	411
query74	5119	5016	4810	4810
query75	2655	2609	2218	2218
query76	2353	1177	804	804
query77	356	370	288	288
query78	12582	12426	11780	11780
query79	1274	1056	780	780
query80	536	482	399	399
query81	457	277	240	240
query82	243	157	120	120
query83	278	277	248	248
query84	274	143	115	115
query85	873	540	443	443
query86	320	297	296	296
query87	3337	3350	3168	3168
query88	3601	2746	2717	2717
query89	408	377	322	322
query90	2203	177	194	177
query91	177	169	143	143
query92	62	62	60	60
query93	1410	1435	925	925
query94	532	364	320	320
query95	688	380	346	346
query96	1105	828	366	366
query97	2696	2708	2597	2597
query98	212	208	209	208
query99	1158	1164	1036	1036
Total cold run time: 250779 ms
Total hot run time: 169325 ms

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.

2 participants