Skip to content

[fix](be) Harden FileScannerV2 schema and reader edge cases#65548

Open
Gabriel39 wants to merge 17 commits into
apache:masterfrom
Gabriel39:codex/fix-file-scanner-v2-review-issues
Open

[fix](be) Harden FileScannerV2 schema and reader edge cases#65548
Gabriel39 wants to merge 17 commits into
apache:masterfrom
Gabriel39:codex/fix-file-scanner-v2-review-issues

Conversation

@Gabriel39

@Gabriel39 Gabriel39 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: FileScannerV2 treated valid empty splits as scan failures, localized promoted nested struct predicates with mismatched operand types, and rejected whole Parquet schemas when unprojected leaves used unsupported logical types. Follow-up review also found that stop EOF could be counted as an empty file, unsupported requested leaves could reach metadata pruning before rejection, and reader-local page-cache range metadata lost warm non-exact reuse while lacking a bound. This change distinguishes stopped reads from empty splits, casts localized nested leaves back to table types, validates requested leaves before pruning and aggregate metadata, and shares bounded per-file range indexes through a bounded directory outside the ReadAt global hot path. Commented unit and regression cases cover empty CSV input, interrupted EOF, mixed Parquet struct leaf types, cross-reader non-exact cache reuse, bounded metadata, unprojected unsupported leaves, and an adjusted TIME_MILLIS predicate that statistics would otherwise prune.

A later review and external regression build exposed a separate COUNT pushdown ambiguity: COUNT(*) retained an arbitrary nullable scan slot after pruning, and BE inferred that placeholder as COUNT(column), producing 9015 instead of 10000 rows for special ORC data and 116 instead of 219 rows for Hive basic types. The fix now carries semantic COUNT arguments from Nereids through thrift to FileScannerV2; an empty argument list remains row-count semantics, while explicit COUNT(column) carries its mapped file column.

Release note

Fix FileScannerV2 compatibility for empty files, stopped reads, evolved nested predicates, and Parquet files containing unsupported logical columns; retain bounded cross-reader Parquet page-cache range reuse without a process-wide ReadAt lock. Also fix COUNT(*) aggregate pushdown when the planner-retained placeholder column contains NULL values.

Check List (For Author)

  • Test: Regression test / Unit Test
    • 56 targeted BE ASAN unit tests from the original change
    • 7 targeted BE ASAN COUNT pushdown unit tests, including the new nullable-placeholder COUNT(*) regression
    • Frontend rule coverage added for COUNT(*) and COUNT(column); execution on Gabriel was blocked by unrelated untracked cloud storage sources missing vendor SDKs
    • Existing external regression cases test_special_orc_formats and test_hive_basic_type reproduce the fixed COUNT(*) failures
    • test_file_scanner_v2_review_fixes regression suite
  • Behavior changed: Yes (valid empty splits are skipped, stop EOF is propagated, unsupported requested Parquet leaves fail before metadata pruning, and COUNT(*) is no longer inferred as COUNT(column))
  • 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?

@Gabriel39 Gabriel39 marked this pull request as ready for review July 13, 2026 11:34
@Gabriel39 Gabriel39 requested a review from yiguolei as a code owner July 13, 2026 11:34
@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Jul 20th, 2026 12:23 AM.
Workflow run: https://github.com/apache/doris/actions/runs/29246737159

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17701	4116	4065	4065
q2	2057	330	206	206
q3	10268	1491	846	846
q4	4684	474	345	345
q5	7599	856	588	588
q6	178	175	135	135
q7	785	859	641	641
q8	9348	1823	1725	1725
q9	5696	4500	4466	4466
q10	6721	1824	1559	1559
q11	508	345	312	312
q12	714	558	416	416
q13	18096	3335	2775	2775
q14	265	260	244	244
q15	q16	793	778	711	711
q17	998	907	1043	907
q18	6966	6002	5579	5579
q19	1309	1208	1084	1084
q20	755	676	596	596
q21	6282	2849	2746	2746
q22	450	376	316	316
Total cold run time: 102173 ms
Total hot run time: 30262 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5120	4803	4763	4763
q2	304	360	221	221
q3	4989	5413	4697	4697
q4	2059	2166	1380	1380
q5	4728	4913	4663	4663
q6	227	179	129	129
q7	1913	1826	1541	1541
q8	2394	2109	2136	2109
q9	7713	7549	7220	7220
q10	4676	4630	4170	4170
q11	521	388	353	353
q12	731	744	531	531
q13	3014	3393	2773	2773
q14	268	273	253	253
q15	q16	678	691	601	601
q17	1269	1250	1250	1250
q18	7453	6938	6977	6938
q19	1111	1063	1102	1063
q20	2212	2224	1926	1926
q21	5238	4508	4418	4418
q22	530	457	416	416
Total cold run time: 57148 ms
Total hot run time: 51415 ms

@hello-stephen

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

query5	4356	634	486	486
query6	446	215	203	203
query7	4849	623	331	331
query8	344	197	174	174
query9	8784	4065	4088	4065
query10	510	335	334	334
query11	5977	2355	2133	2133
query12	168	104	102	102
query13	1252	602	408	408
query14	6220	5228	4946	4946
query14_1	4261	4268	4278	4268
query15	208	203	181	181
query16	1020	485	466	466
query17	1087	740	574	574
query18	2422	462	340	340
query19	207	187	148	148
query20	111	111	115	111
query21	244	160	129	129
query22	13523	13609	13462	13462
query23	17470	16568	16136	16136
query23_1	16307	16293	16273	16273
query24	7575	1804	1331	1331
query24_1	1309	1324	1298	1298
query25	571	473	392	392
query26	1335	345	222	222
query27	2585	627	394	394
query28	4461	2036	2028	2028
query29	1087	646	509	509
query30	337	264	227	227
query31	1131	1094	991	991
query32	122	63	61	61
query33	519	330	257	257
query34	1164	1144	644	644
query35	769	792	673	673
query36	1432	1435	1269	1269
query37	151	106	99	99
query38	1875	1688	1647	1647
query39	918	932	871	871
query39_1	879	887	878	878
query40	248	168	145	145
query41	76	71	70	70
query42	97	98	93	93
query43	318	325	280	280
query44	1437	772	768	768
query45	202	190	180	180
query46	1056	1199	764	764
query47	2455	2432	2283	2283
query48	400	402	316	316
query49	614	439	328	328
query50	1088	429	341	341
query51	10789	10938	10884	10884
query52	89	94	79	79
query53	277	287	213	213
query54	294	248	246	246
query55	82	72	68	68
query56	314	324	302	302
query57	1462	1425	1335	1335
query58	304	274	248	248
query59	1571	1622	1477	1477
query60	334	304	268	268
query61	201	151	150	150
query62	713	653	592	592
query63	236	203	198	198
query64	2854	1066	844	844
query65	4855	4756	4776	4756
query66	1814	513	382	382
query67	29601	29403	29397	29397
query68	2992	1559	1020	1020
query69	405	306	263	263
query70	1064	970	937	937
query71	352	324	299	299
query72	3138	2827	2400	2400
query73	788	825	443	443
query74	5142	4995	4796	4796
query75	2603	2608	2229	2229
query76	2324	1183	792	792
query77	357	379	283	283
query78	12388	12502	11656	11656
query79	1392	1162	762	762
query80	1293	579	474	474
query81	522	318	286	286
query82	630	161	124	124
query83	362	322	294	294
query84	294	164	131	131
query85	971	596	512	512
query86	421	310	253	253
query87	1820	1830	1768	1768
query88	3661	2793	2747	2747
query89	454	407	352	352
query90	1932	201	187	187
query91	202	195	164	164
query92	62	63	59	59
query93	1596	1528	918	918
query94	722	358	329	329
query95	789	596	474	474
query96	1030	860	346	346
query97	2698	2713	2580	2580
query98	227	223	197	197
query99	1162	1177	1021	1021
Total cold run time: 265983 ms
Total hot run time: 180840 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.10	0.05	0.05
query3	0.26	0.14	0.13
query4	1.61	0.14	0.14
query5	0.25	0.25	0.22
query6	1.26	1.08	1.04
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.37	0.31	0.31
query10	0.55	0.54	0.56
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.47	0.49
query14	1.01	1.00	1.02
query15	0.60	0.59	0.60
query16	0.31	0.32	0.31
query17	1.12	1.10	1.13
query18	0.23	0.21	0.21
query19	2.02	2.03	1.96
query20	0.02	0.01	0.01
query21	15.46	0.23	0.14
query22	4.87	0.06	0.06
query23	16.12	0.31	0.13
query24	3.02	0.44	0.32
query25	0.12	0.04	0.03
query26	0.73	0.22	0.16
query27	0.04	0.04	0.04
query28	3.57	0.89	0.56
query29	12.49	4.08	3.18
query30	0.27	0.15	0.16
query31	2.77	0.61	0.31
query32	3.21	0.59	0.48
query33	3.15	3.29	3.17
query34	15.63	4.23	3.53
query35	3.51	3.52	3.53
query36	0.54	0.43	0.44
query37	0.08	0.06	0.07
query38	0.06	0.04	0.04
query39	0.03	0.03	0.03
query40	0.18	0.16	0.15
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.67 s
Total hot run time: 24.99 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 67.69% (44/65) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.01% (23635/41458)
Line Coverage 40.68% (231256/568436)
Region Coverage 36.58% (182762/499619)
Branch Coverage 37.69% (81680/216740)

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Jul 20th, 2026 12:23 AM.
Workflow run: https://github.com/apache/doris/actions/runs/29255600260

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@Gabriel39

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.

I found four issues that should be fixed before merging.

Checkpoint summary: the PR is focused on FileScannerV2/format-v2 edge cases and has useful unit/regression coverage, but the current implementation still has correctness issues around stop-vs-empty EOF handling and unsupported Parquet logical types. The page-cache range refactor also introduces two performance/lifecycle regressions: non-exact warm-cache reuse is lost across readers, and the new reader-local index is unbounded. I did not run BE/regression tests in this review-only runner; the checkout is a single shallow commit with the base/parent SHA unavailable, so validation was static against the bundled authoritative PR diff and GitHub PR metadata. User focus: no additional focus points were provided.

Comment thread be/src/exec/scan/file_scanner_v2.cpp Outdated
Comment thread be/src/format_v2/parquet/parquet_column_schema.cpp
Comment thread be/src/format_v2/parquet/parquet_file_context.cpp Outdated
Comment thread be/src/format_v2/parquet/parquet_file_context.cpp
@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

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

I found two remaining correctness issues after the current fixes: primitive COUNT(column) aggregate pushdown can still bypass the unsupported Parquet logical-type validation, and the generic EOF skip can still downgrade a malformed Native file into an empty split. I rechecked the scanner EOF, unsupported Parquet type, nested column-mapper, and page-cache range-directory surfaces against the existing review threads and did not find additional distinct findings.

Validation was static only; I did not run builds or tests because this review invocation is read-only per the bundled prompt.

Comment thread be/src/format_v2/parquet/parquet_reader.cpp
Comment thread be/src/exec/scan/file_scanner_v2.cpp
@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 83.13% (138/166) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.10% (23692/41495)
Line Coverage 40.80% (232166/569029)
Region Coverage 36.65% (183337/500274)
Branch Coverage 37.79% (82071/217148)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17656	4100	4127	4100
q2	2027	336	203	203
q3	10274	1467	843	843
q4	4684	479	338	338
q5	7557	860	570	570
q6	188	170	140	140
q7	774	838	617	617
q8	9333	1621	1546	1546
q9	5651	4483	4403	4403
q10	6857	1822	1539	1539
q11	500	345	324	324
q12	696	560	436	436
q13	18085	3401	2728	2728
q14	279	263	239	239
q15	q16	791	783	711	711
q17	1024	926	1039	926
q18	7246	5876	5598	5598
q19	1287	1207	1020	1020
q20	751	667	514	514
q21	5913	2684	2562	2562
q22	435	368	302	302
Total cold run time: 102008 ms
Total hot run time: 29659 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4617	4305	4322	4305
q2	295	317	222	222
q3	4647	5030	4422	4422
q4	2080	2168	1369	1369
q5	4522	4385	4369	4369
q6	227	176	131	131
q7	1915	2099	1724	1724
q8	2627	2283	2257	2257
q9	8267	8290	7892	7892
q10	4765	4732	4287	4287
q11	604	437	369	369
q12	767	773	557	557
q13	3308	3543	2988	2988
q14	310	301	278	278
q15	q16	726	746	661	661
q17	1390	1420	1362	1362
q18	8020	7518	7306	7306
q19	1128	1158	1074	1074
q20	2198	2220	1936	1936
q21	5385	4706	4518	4518
q22	521	461	392	392
Total cold run time: 58319 ms
Total hot run time: 52419 ms

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

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.

I found one remaining correctness issue in the COUNT aggregate request construction. The rest of the reviewed areas look covered by the current fixes or by existing review threads.

Checkpoint conclusions: the PR goal is clear and mostly addressed; the change is focused around FileScannerV2/format-v2 review fixes; I did not find new concurrency or lifecycle problems in the scanner stop/empty split or page-cache range-directory paths; no new config or persistence compatibility changes are introduced; existing parallel paths were checked for scanner EOF, Parquet/ORC aggregate semantics, and page-cache behavior; test coverage was reviewed statically but not run in this review-only environment; observability changes are limited to the empty-file counter and look consistent. User focus: no additional user-provided focus beyond the full PR 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.

Correcting the inline anchor for the COUNT aggregate request construction issue; see inline.

Comment thread be/src/format_v2/table_reader.h Outdated
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17696	4106	4103	4103
q2	2037	340	205	205
q3	10254	1438	841	841
q4	4689	496	343	343
q5	7518	865	591	591
q6	183	175	139	139
q7	782	824	631	631
q8	9375	1584	1659	1584
q9	5587	4396	4348	4348
q10	6768	1811	1499	1499
q11	507	344	315	315
q12	713	571	421	421
q13	18183	3321	2764	2764
q14	282	268	236	236
q15	q16	790	793	723	723
q17	958	1006	991	991
q18	7571	5742	5443	5443
q19	1325	1258	1056	1056
q20	758	666	562	562
q21	6404	2882	2777	2777
q22	471	392	321	321
Total cold run time: 102851 ms
Total hot run time: 29893 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5150	4750	5218	4750
q2	301	335	222	222
q3	4956	5291	4719	4719
q4	2109	2191	1373	1373
q5	4944	4716	4665	4665
q6	231	182	128	128
q7	1978	1738	1548	1548
q8	2400	2119	2150	2119
q9	7617	7154	7184	7154
q10	4634	4560	4130	4130
q11	534	388	354	354
q12	737	758	531	531
q13	3033	3357	2797	2797
q14	274	282	252	252
q15	q16	683	693	610	610
q17	1283	1248	1238	1238
q18	7406	6868	7006	6868
q19	1077	1068	1052	1052
q20	2226	2221	1951	1951
q21	5267	4598	4447	4447
q22	523	452	429	429
Total cold run time: 57363 ms
Total hot run time: 51337 ms

@hello-stephen

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

query5	4323	642	491	491
query6	485	220	198	198
query7	4855	621	344	344
query8	361	187	174	174
query9	8757	4037	4033	4033
query10	478	393	319	319
query11	5946	2330	2132	2132
query12	164	108	106	106
query13	1321	608	416	416
query14	6259	5256	4885	4885
query14_1	4268	4270	4229	4229
query15	216	205	179	179
query16	1013	475	476	475
query17	954	727	599	599
query18	2485	480	351	351
query19	228	193	154	154
query20	113	108	111	108
query21	238	155	135	135
query22	13579	13501	13262	13262
query23	17553	16550	16073	16073
query23_1	16226	16210	16308	16210
query24	7539	1784	1286	1286
query24_1	1324	1270	1279	1270
query25	574	470	399	399
query26	1339	336	208	208
query27	2639	570	359	359
query28	4433	2018	2003	2003
query29	1103	634	501	501
query30	338	262	234	234
query31	1123	1097	970	970
query32	131	63	64	63
query33	536	356	294	294
query34	1184	1100	640	640
query35	764	801	654	654
query36	1198	1196	1040	1040
query37	152	110	95	95
query38	1885	1698	1597	1597
query39	878	898	836	836
query39_1	827	840	852	840
query40	260	157	142	142
query41	66	64	63	63
query42	92	91	91	91
query43	321	324	280	280
query44	1392	772	777	772
query45	188	185	180	180
query46	1072	1170	763	763
query47	2152	2142	2054	2054
query48	383	388	289	289
query49	592	408	333	333
query50	996	393	323	323
query51	10996	10692	10941	10692
query52	86	87	76	76
query53	261	279	203	203
query54	284	239	215	215
query55	73	72	65	65
query56	304	279	273	273
query57	1328	1290	1232	1232
query58	305	267	264	264
query59	1579	1668	1463	1463
query60	310	275	254	254
query61	151	152	150	150
query62	545	498	436	436
query63	241	197	197	197
query64	2894	1063	838	838
query65	4697	4614	4652	4614
query66	1836	504	380	380
query67	29388	29303	29095	29095
query68	3078	1527	928	928
query69	400	300	347	300
query70	1107	1022	958	958
query71	364	313	292	292
query72	3092	2692	2479	2479
query73	845	756	426	426
query74	5038	4926	4719	4719
query75	2511	2541	2119	2119
query76	2365	1170	801	801
query77	354	367	282	282
query78	11970	11806	11311	11311
query79	1448	1138	732	732
query80	1305	540	449	449
query81	526	311	273	273
query82	1069	155	120	120
query83	395	318	292	292
query84	325	157	135	135
query85	985	602	508	508
query86	451	300	288	288
query87	1826	1825	1757	1757
query88	3706	2820	2817	2817
query89	434	384	326	326
query90	1921	190	195	190
query91	212	192	173	173
query92	66	65	57	57
query93	1592	1504	1041	1041
query94	845	374	326	326
query95	769	578	469	469
query96	1030	799	381	381
query97	2647	2651	2489	2489
query98	216	206	201	201
query99	1082	1113	969	969
Total cold run time: 264932 ms
Total hot run time: 178193 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.10	0.05	0.05
query3	0.28	0.14	0.14
query4	1.61	0.14	0.15
query5	0.27	0.22	0.22
query6	1.25	1.07	1.10
query7	0.04	0.00	0.00
query8	0.06	0.04	0.03
query9	0.38	0.33	0.31
query10	0.56	0.55	0.58
query11	0.20	0.14	0.15
query12	0.18	0.15	0.16
query13	0.49	0.48	0.47
query14	1.04	1.02	1.01
query15	0.61	0.58	0.59
query16	0.34	0.34	0.33
query17	1.08	1.12	1.08
query18	0.23	0.23	0.22
query19	2.01	1.93	1.92
query20	0.01	0.02	0.01
query21	15.46	0.22	0.13
query22	4.91	0.06	0.05
query23	16.10	0.30	0.12
query24	2.89	0.40	0.32
query25	0.12	0.04	0.05
query26	0.75	0.20	0.14
query27	0.06	0.04	0.04
query28	3.51	0.92	0.53
query29	12.51	4.09	3.23
query30	0.27	0.15	0.17
query31	2.78	0.59	0.31
query32	3.22	0.59	0.49
query33	3.21	3.15	3.21
query34	15.52	4.23	3.54
query35	3.58	3.56	3.55
query36	0.56	0.44	0.42
query37	0.10	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.16	0.16
query41	0.10	0.03	0.02
query42	0.04	0.04	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.75 s
Total hot run time: 25.01 s

Gabriel39 added a commit to Gabriel39/incubator-doris that referenced this pull request Jul 14, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65548

Problem Summary: File aggregate pushdown inferred COUNT(column) from a single post-pruning scan mapping. COUNT(*) also retains an arbitrary placeholder slot, so a nullable placeholder made Parquet and ORC readers count non-null values instead of rows. Carry the semantic COUNT arguments from Nereids through the scan thrift contract, keep true COUNT(*) column-free, and fall back when an explicit COUNT argument cannot be mapped directly. Also default split-level conjunct overrides to nullopt so existing standalone readers compile and preserve their initial predicate snapshot.

### Release note

Fix COUNT(*) results for Parquet and ORC file scans when the retained placeholder column contains NULL values.

### Check List (For Author)

- Test: Unit Test
    - 7 targeted Backend ASAN unit tests
    - Added Frontend rule coverage for COUNT(*) and COUNT(column); execution was blocked by unrelated untracked cloud storage sources missing vendor SDKs in the validation workspace
- Behavior changed: Yes (file aggregate pushdown now distinguishes COUNT(*) from COUNT(column) explicitly)
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 17.39% (28/161) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?\n\nFile-local struct predicates could hide lossy materialization errors, and Hive/TVF treated COUNT(column) like metadata-only COUNT(*).\n\nIssue Number: None\n\n### Release note\n\nNone\n\n### Check List\n\n- [x] Regression tests\n- [x] Code format
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

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.

Reviewed current head 48ab9ca23554fe64eaf8cb06beaa96d571a7027f. One additional distinct performance issue remains: FileScannerV2 disables adaptive batch sizing even when the new COUNT guards fall back to materializing normal rows. See the inline comment.

Checkpoint conclusions:

  • Goal and scope: the patch consistently hardens FileScannerV2 schema/reader edge cases and carries explicit COUNT semantics through the same-version FE-to-BE path; the changes remain focused on those behaviors and their tests.
  • Correctness and lifecycle: current-head empty-split handling advances each range once; COUNT(*)/COUNT(col), placeholder, delete, unsupported-Parquet-type, and nested-predicate result semantics are coherent apart from concerns already recorded in existing threads.
  • Concurrency and performance: the shared Parquet page-range directory is bounded, version-keyed, and mutex-protected without a reverse lock order found. The accepted inline finding covers the remaining COUNT-fallback batch-size/memory regression.
  • Compatibility and parallel paths: same-version V1/V2, Hive/TVF, Iceberg, Paimon, Parquet, ORC, and Native paths were checked. The mixed-version COUNT/split-reduction risk remains covered by the existing rolling-upgrade discussion, so I did not duplicate it.
  • Tests and observability: the patch adds targeted BE, FE, and regression coverage plus the EmptyFileNum profile counter. Per the review contract, I did not run local builds/tests; CI evidence should remain the validation source.
  • Configuration, persistence, transactions, and writes: no new configuration propagation, persisted state, transactional boundary, or data-write path is introduced.

There was no additional user-provided review focus. Existing unresolved review threads remain authoritative.

Comment thread be/src/format_v2/table_reader.h
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 70.73% (29/41) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#65548

Problem Summary: FileScannerV2 disabled adaptive batch sizing whenever the FE sent COUNT, even when TableReader rejected metadata COUNT because of multiple arguments, unsafe mappings, filters, or deletes. Those fallback scans materialized normal rows using the fixed runtime batch size, inflating block memory for wide columns. Track whether the active split actually emits metadata-derived COUNT rows and suppress adaptive sizing only in that case; fallback scans retain the first-batch probe and predictor updates.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - FileScannerV2Test.AdaptiveBatchSizeRunsForCountFallbackOnly
    - TableReaderTest COUNT coverage
- Behavior changed: No. Query results are unchanged; normal COUNT fallback scans retain adaptive batch sizing.
- Does this need documentation: No
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.62% (1908/2458)
Line Coverage 64.45% (34134/52966)
Region Coverage 64.88% (17568/27076)
Branch Coverage 54.04% (9416/17424)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17820	4158	4163	4158
q2	2005	316	205	205
q3	10291	1452	809	809
q4	4733	464	338	338
q5	7854	852	572	572
q6	249	174	137	137
q7	792	819	609	609
q8	10364	1547	1614	1547
q9	5998	4355	4385	4355
q10	6798	1763	1474	1474
q11	505	353	323	323
q12	751	585	448	448
q13	18147	3335	2737	2737
q14	273	266	248	248
q15	q16	788	784	705	705
q17	1070	991	1056	991
q18	7001	5660	5562	5562
q19	1307	1248	1121	1121
q20	854	717	577	577
q21	5748	2647	2440	2440
q22	442	358	294	294
Total cold run time: 103790 ms
Total hot run time: 29650 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4430	4405	4395	4395
q2	299	328	217	217
q3	4573	5000	4366	4366
q4	2092	2162	1354	1354
q5	4404	4275	4327	4275
q6	232	178	132	132
q7	2319	2005	1727	1727
q8	2609	2321	2301	2301
q9	8160	8021	7737	7737
q10	4710	4636	4231	4231
q11	600	449	403	403
q12	772	764	538	538
q13	3327	3705	2897	2897
q14	291	297	274	274
q15	q16	720	718	634	634
q17	1412	1361	1487	1361
q18	8006	7583	7372	7372
q19	1128	1090	1097	1090
q20	2217	2192	1915	1915
q21	5297	4664	4388	4388
q22	524	475	393	393
Total cold run time: 58122 ms
Total hot run time: 52000 ms

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

Request changes: two new P2 issues remain on the current head.

  • Native Hudi COW COUNT plans reach FileScannerV2, but the new COUNT-argument state stops at the outer hybrid reader. The child therefore rejects metadata aggregation and turns footer/stripe COUNT into a full base-file scan.
  • The new local() TVF COUNT regression never activates storage-layer aggregation in production, so it cannot exercise the protocol or mapping fallback it claims to cover.

Critical checkpoint conclusions:

  • Goal and proof: The patch fixes many FileScannerV2 schema, EOF, COUNT, and cache edge cases, but the goal is not fully proven because the Hudi wrapper loses the new state and the TVF COUNT regression is an ordinary scan.
  • Scope and clarity: The changes are broad but cohesive around scanner-v2 hardening. Most safety conditions are documented; no unrelated code was found.
  • Concurrency and thread safety: The shared Parquet cache directory uses bounded, per-file locked state and validates payload hits; lock work and eviction behavior did not reveal a new correctness or deadlock issue.
  • Lifecycle and static state: Split prepare/abort/close and adaptive-state resets are balanced on direct readers, with no cross-TU initialization concern. The active-child lifecycle/state handoff missing from the Hudi hybrid is covered inline.
  • Configuration: No new configuration item is introduced. Existing default-enabled FileScannerV2 and external COUNT pushdown make the Hudi regression reachable.
  • Compatibility: Current-version FE-to-V1/direct-V2 COUNT semantics are consistent. Mixed-version ambiguity remains covered by the existing rolling-upgrade thread and was not duplicated here.
  • Parallel paths and conditions: V1, direct V2, Hive, Iceberg, Paimon, Hudi, and TVF paths were traced. The new field is handled in direct paths but not the reachable Hudi child wrapper.
  • Tests and results: The added unit/regression coverage is substantial and expected outputs are deterministic, but the TVF COUNT case does not reach the feature under test and there is no Hudi hybrid COUNT-state test. Per the review-task contract, this was a static review; no build or test command was run.
  • Observability: New empty-file and adaptive counters are appropriate for the changed lifecycle. No additional logging/metric blocker was found.
  • Transactions, persistence, and writes: Not applicable; these changes are read-path scanner/planner logic and introduce no persisted state or data mutation.
  • FE-BE variables: Thrift serialization, local-state storage, ExprId/SlotId/global-index mapping, and V1/direct-V2 consumption were checked. The same state is not forwarded when Hudi reconstructs child TableReadOptions.
  • Performance: The Hudi full-scan fallback is the new actionable regression. Cache lookup, mapper localization, and direct adaptive batching showed no other new issue.
  • Other correctness: Placeholder/delete row alignment, unsupported Parquet leaves, nested nullability/casts, EOF/stop cleanup, and split ownership were rechecked. Remaining live concerns are already represented by existing review threads and were duplicate-suppressed.

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

Corrected inline anchor for the Hudi hybrid COUNT-state finding from review 4711618828.

Comment thread be/src/exec/scan/file_scanner_v2.cpp
@hello-stephen

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

query5	4327	631	497	497
query6	447	225	218	218
query7	4860	582	328	328
query8	334	197	172	172
query9	8756	4133	4112	4112
query10	463	370	304	304
query11	5901	2314	2141	2141
query12	158	110	101	101
query13	1267	609	437	437
query14	6271	5270	4932	4932
query14_1	4306	4265	4291	4265
query15	210	206	182	182
query16	1031	473	480	473
query17	1118	763	592	592
query18	2488	475	362	362
query19	214	194	157	157
query20	113	112	109	109
query21	235	161	148	148
query22	13604	13558	13362	13362
query23	17405	16367	16118	16118
query23_1	16202	16276	16264	16264
query24	7516	1746	1271	1271
query24_1	1301	1296	1304	1296
query25	571	474	416	416
query26	1358	352	213	213
query27	2579	650	401	401
query28	4428	2004	2011	2004
query29	1090	632	496	496
query30	347	265	228	228
query31	1117	1083	981	981
query32	100	63	60	60
query33	539	338	260	260
query34	1180	1117	673	673
query35	776	789	672	672
query36	1184	1185	1079	1079
query37	157	110	97	97
query38	1864	1716	1672	1672
query39	876	898	850	850
query39_1	834	848	845	845
query40	241	164	143	143
query41	65	63	64	63
query42	91	90	96	90
query43	324	320	276	276
query44	1424	780	755	755
query45	198	176	172	172
query46	1081	1148	744	744
query47	2141	2055	1985	1985
query48	413	423	289	289
query49	583	437	307	307
query50	1069	443	336	336
query51	10345	10529	10384	10384
query52	85	86	77	77
query53	265	280	196	196
query54	280	230	218	218
query55	73	71	68	68
query56	294	296	290	290
query57	1293	1261	1192	1192
query58	281	252	272	252
query59	1551	1629	1436	1436
query60	304	272	253	253
query61	151	149	185	149
query62	543	497	426	426
query63	257	198	209	198
query64	2811	1065	876	876
query65	4713	4634	4584	4584
query66	1798	526	384	384
query67	29340	29110	29103	29103
query68	3110	1507	1035	1035
query69	411	301	260	260
query70	1038	985	954	954
query71	370	347	308	308
query72	3015	2624	2362	2362
query73	825	775	441	441
query74	5051	4883	4688	4688
query75	2544	2509	2142	2142
query76	2303	1174	754	754
query77	343	408	286	286
query78	11972	12030	11203	11203
query79	1415	1158	740	740
query80	691	559	500	500
query81	467	339	290	290
query82	573	159	125	125
query83	397	335	303	303
query84	279	162	131	131
query85	940	612	518	518
query86	369	296	286	286
query87	1822	1810	1746	1746
query88	3722	2776	2750	2750
query89	439	376	327	327
query90	1958	213	193	193
query91	210	191	166	166
query92	64	69	57	57
query93	1682	1507	987	987
query94	556	370	340	340
query95	809	503	554	503
query96	1003	809	353	353
query97	2611	2595	2481	2481
query98	226	202	198	198
query99	1077	1101	971	971
Total cold run time: 262172 ms
Total hot run time: 177292 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.10	0.05	0.05
query3	0.25	0.16	0.14
query4	1.62	0.14	0.13
query5	0.24	0.23	0.21
query6	1.24	1.04	1.08
query7	0.04	0.01	0.01
query8	0.06	0.03	0.04
query9	0.37	0.31	0.31
query10	0.57	0.55	0.57
query11	0.20	0.14	0.14
query12	0.17	0.14	0.14
query13	0.48	0.46	0.48
query14	1.01	1.00	0.99
query15	0.61	0.58	0.60
query16	0.33	0.32	0.31
query17	1.08	1.09	1.09
query18	0.22	0.20	0.20
query19	2.03	1.95	1.96
query20	0.02	0.01	0.01
query21	15.43	0.19	0.14
query22	4.95	0.05	0.05
query23	16.14	0.31	0.11
query24	2.97	0.42	0.30
query25	0.10	0.06	0.05
query26	0.73	0.20	0.16
query27	0.04	0.04	0.03
query28	3.53	0.88	0.53
query29	12.50	4.07	3.28
query30	0.27	0.15	0.15
query31	2.77	0.59	0.32
query32	3.23	0.59	0.48
query33	3.28	3.17	3.25
query34	15.61	4.23	3.52
query35	3.51	3.57	3.51
query36	0.56	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.16	0.16
query41	0.09	0.03	0.03
query42	0.03	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.8 s
Total hot run time: 24.94 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#65548

Problem Summary: HudiHybridReader and PaimonHybridReader forwarded the aggregate opcode to their active child readers but dropped the optional COUNT argument state. New BEs therefore treated explicit COUNT(*) and safe COUNT(column) plans as unknown old-FE semantics and fell back to full row scans. The hybrid wrappers also hid the child metadata-COUNT state from FileScannerV2, allowing synthetic aggregate rows to reach adaptive batch-size sampling. Forward COUNT arguments to both native and JNI children and delegate the active split metadata state through the hybrid reader.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - HudiHybridReaderTest.*
    - PaimonHybridReaderTest.*
    - FileScannerV2 and TableReader COUNT coverage
- Behavior changed: No. Query results are unchanged; eligible Hudi and Paimon COUNT scans retain metadata aggregation and correct adaptive-batch accounting.
- Does this need documentation: No
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17711	4188	4335	4188
q2	2035	328	201	201
q3	10296	1484	835	835
q4	4682	519	339	339
q5	7493	853	574	574
q6	195	187	143	143
q7	785	815	609	609
q8	9312	1575	1529	1529
q9	5608	4376	4334	4334
q10	6802	1728	1452	1452
q11	536	356	340	340
q12	714	577	467	467
q13	18082	3455	2734	2734
q14	265	263	249	249
q15	q16	790	784	712	712
q17	1061	1125	874	874
q18	6944	5800	5698	5698
q19	1152	1387	1111	1111
q20	795	682	610	610
q21	5573	2653	2457	2457
q22	437	355	303	303
Total cold run time: 101268 ms
Total hot run time: 29759 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4601	4546	4570	4546
q2	298	328	217	217
q3	4600	4998	4420	4420
q4	2133	2171	1409	1409
q5	4387	4340	4312	4312
q6	232	177	135	135
q7	1886	2100	1721	1721
q8	2622	2217	2217	2217
q9	7900	8048	7886	7886
q10	4703	4636	4196	4196
q11	588	471	439	439
q12	754	774	541	541
q13	3297	3595	2920	2920
q14	309	315	274	274
q15	q16	727	760	673	673
q17	1368	1384	1338	1338
q18	8148	7575	7275	7275
q19	1161	1079	1094	1079
q20	2229	2202	1937	1937
q21	5341	4681	4503	4503
q22	528	495	404	404
Total cold run time: 57812 ms
Total hot run time: 52442 ms

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

Completed a static review of head d74d2c3f00ee981b026f10bd0c7579e083ab5e09 against base ec716229c84bfd9a67c18c2e61913f651e02e1c4, including all 55 changed files, the required FileScannerV2 design material, and the existing review threads. I found no new nonduplicate actionable issue to add; remaining concerns are already represented by existing inline threads.

Checkpoint conclusions:

  • Goal and result correctness: current-version planning preserves explicit COUNT semantics from Nereids ExprIds through Thrift SlotIds and V1/V2 scanner dispatch, with empty/non-empty/absent states kept distinct. Table-level and file-level metadata paths now use those semantics, and Hudi/Paimon hybrid readers forward/reset the active child state used by adaptive batching.
  • Scanner and format paths: reviewed V1/V2, Hive/TVF/Iceberg/Paimon/Hudi, and Parquet/ORC/Native paths, including split reduction, placeholders, position/equality/deletion-vector dependencies, zero-row handling, unsupported Parquet logical leaves, and nested-struct predicate localization. The mixed-version COUNT protocol, Native zero-byte short-read EOF, and unreachable TVF COUNT regression remain covered by existing threads and were not duplicated.
  • Concurrency and lifecycle: the shared Parquet page-cache directory and per-file range indices are bounded, snapshots are taken under the per-index lock, stale payload metadata falls back to a full base read, and no reverse lock order or stale-byte path was substantiated. Reader close/abort and hybrid split transitions reset or delegate split-scoped metadata state consistently; the function-local static directory has process lifetime without cross-translation-unit initialization dependencies.
  • Scope and interfaces: changes are focused on scanner/planner/format behavior and tests. No new configuration, persistence, transaction/write, or security boundary applies. The new optional FE/BE field is safe for current/current execution; its rolling-upgrade limitation is the existing compatibility thread.
  • Performance and observability: metadata COUNT no longer suppresses adaptive sizing on row-scan fallbacks, placeholder columns avoid unnecessary Parquet validation/decoding, page-cache discovery remains shared but bounded, and empty-file/adaptive counters follow the reviewed paths.
  • Tests: the patch adds focused BE and FE unit coverage plus external-table regression fixtures. The TVF end-to-end COUNT case does not reach storage aggregate pushdown, as already reported. This review was static only: the prepared checkout has no initialized worktree dependencies or thirdparty/installed/bin/protoc, and the review contract prohibited builds or source changes. The macOS BE-unit job currently fails before tests because the runner supplies Java 25 while Doris requires JDK 17.

No additional review focus was provided. Existing inline threads remain the source of truth for unresolved items.

@hello-stephen

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

query5	4346	622	493	493
query6	471	234	206	206
query7	4957	567	355	355
query8	357	196	184	184
query9	8763	4159	4107	4107
query10	489	358	298	298
query11	5824	2347	2136	2136
query12	167	105	102	102
query13	1277	593	426	426
query14	6252	5311	4951	4951
query14_1	4308	4330	4331	4330
query15	215	216	181	181
query16	1065	488	465	465
query17	1123	727	592	592
query18	2564	484	360	360
query19	212	194	151	151
query20	114	109	118	109
query21	236	163	137	137
query22	13548	13612	13440	13440
query23	17331	16547	16071	16071
query23_1	16215	16241	16187	16187
query24	7663	1759	1263	1263
query24_1	1298	1280	1305	1280
query25	559	474	401	401
query26	1356	360	221	221
query27	2580	583	388	388
query28	4494	2002	2029	2002
query29	1105	623	512	512
query30	346	257	229	229
query31	1144	1107	984	984
query32	119	64	63	63
query33	531	328	266	266
query34	1175	1121	644	644
query35	769	779	672	672
query36	1204	1156	1044	1044
query37	158	106	92	92
query38	1880	1736	1686	1686
query39	868	864	858	858
query39_1	829	822	839	822
query40	241	160	144	144
query41	65	62	61	61
query42	94	91	92	91
query43	338	331	280	280
query44	1415	773	763	763
query45	194	185	174	174
query46	1061	1218	730	730
query47	2076	2071	1993	1993
query48	387	395	280	280
query49	571	409	304	304
query50	1094	437	339	339
query51	10749	10680	10840	10680
query52	95	89	80	80
query53	261	278	204	204
query54	282	245	226	226
query55	74	69	65	65
query56	285	300	277	277
query57	1316	1271	1189	1189
query58	289	279	248	248
query59	1624	1697	1430	1430
query60	304	266	250	250
query61	152	146	143	143
query62	548	498	434	434
query63	263	199	199	199
query64	2780	1040	865	865
query65	4712	4652	4643	4643
query66	1844	560	382	382
query67	29200	29224	29033	29033
query68	3078	1600	978	978
query69	420	292	256	256
query70	1070	979	923	923
query71	374	352	327	327
query72	3082	2637	2358	2358
query73	812	759	427	427
query74	5076	4966	4714	4714
query75	2558	2484	2154	2154
query76	2345	1206	805	805
query77	364	380	279	279
query78	11870	11911	11399	11399
query79	1409	1164	775	775
query80	1288	545	466	466
query81	579	343	292	292
query82	650	155	121	121
query83	405	327	296	296
query84	281	163	136	136
query85	1018	585	531	531
query86	450	313	279	279
query87	1838	1824	1753	1753
query88	3735	2777	2763	2763
query89	449	392	342	342
query90	1962	203	199	199
query91	208	187	157	157
query92	61	61	59	59
query93	1697	1494	993	993
query94	739	361	319	319
query95	808	605	475	475
query96	1071	822	357	357
query97	2640	2642	2486	2486
query98	213	202	199	199
query99	1117	1118	995	995
Total cold run time: 264203 ms
Total hot run time: 177884 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.10	0.05	0.05
query3	0.26	0.15	0.14
query4	1.60	0.14	0.14
query5	0.29	0.23	0.22
query6	1.25	1.09	1.08
query7	0.04	0.01	0.01
query8	0.06	0.04	0.03
query9	0.39	0.32	0.33
query10	0.58	0.57	0.56
query11	0.20	0.14	0.14
query12	0.18	0.15	0.14
query13	0.49	0.49	0.47
query14	1.03	1.04	1.02
query15	0.62	0.59	0.59
query16	0.32	0.33	0.34
query17	1.10	1.10	1.15
query18	0.24	0.23	0.23
query19	2.08	1.97	1.95
query20	0.01	0.02	0.01
query21	15.44	0.23	0.13
query22	4.78	0.05	0.05
query23	16.12	0.31	0.13
query24	2.98	0.43	0.34
query25	0.12	0.05	0.04
query26	0.73	0.21	0.16
query27	0.05	0.04	0.03
query28	3.59	0.92	0.55
query29	12.48	4.20	3.30
query30	0.27	0.16	0.15
query31	2.77	0.60	0.32
query32	3.22	0.59	0.50
query33	3.18	3.35	3.21
query34	15.47	4.23	3.50
query35	3.52	3.52	3.57
query36	0.56	0.44	0.43
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.19	0.17	0.15
query41	0.08	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.65 s
Total hot run time: 25.26 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#65548

Problem Summary: Nested fallback tests required the source column to stay in predicate_columns even though unsafe predicates remain table-level and readers may classify the required source as non-predicate. Verify the stable scan contract instead: the source column is scanned exactly once with the expected file-local id and no file conjunct is produced.

### Release note

None

### Check List (For Author)

- Test: Unit Test
  - ./run-be-ut.sh --run --filter="ColumnMapperCastTest.NestedElementAtConjunctStaysTableLevelForNullableFileLeafMappedToRequiredTableLeaf:ColumnMapperCastTest.NestedElementAtConjunctStaysTableLevelForNonLosslessFileToTableCast" (2 tests passed)
  - ./run-be-ut.sh --run --filter="ColumnMapper*.*" (111 tests passed)
- Behavior changed: No
- Does this need documentation: No
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17696	4182	4170	4170
q2	2004	327	196	196
q3	10321	1455	848	848
q4	4677	476	342	342
q5	7521	953	580	580
q6	192	195	140	140
q7	789	839	628	628
q8	9352	1539	1594	1539
q9	5564	4367	4419	4367
q10	6777	1735	1485	1485
q11	517	384	329	329
q12	712	597	463	463
q13	18081	3365	2796	2796
q14	263	268	244	244
q15	q16	771	780	711	711
q17	994	1119	1009	1009
q18	6912	5851	5598	5598
q19	1152	1240	1101	1101
q20	791	659	560	560
q21	5612	2634	2401	2401
q22	452	358	305	305
Total cold run time: 101150 ms
Total hot run time: 29812 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4436	4399	4387	4387
q2	305	326	214	214
q3	4566	5008	4415	4415
q4	2093	2163	1370	1370
q5	4443	4355	4338	4338
q6	234	180	131	131
q7	1731	2062	1813	1813
q8	2629	2305	2311	2305
q9	8054	8240	7700	7700
q10	4694	4673	4197	4197
q11	604	405	387	387
q12	753	792	558	558
q13	3385	3576	2962	2962
q14	301	317	288	288
q15	q16	710	760	646	646
q17	1380	1375	1374	1374
q18	8112	7385	7463	7385
q19	1210	1115	1076	1076
q20	2219	2184	1938	1938
q21	5352	4615	4503	4503
q22	521	455	419	419
Total cold run time: 57732 ms
Total hot run time: 52406 ms

@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 completed for head 011533388043153e9134c1f6925d3ef0b0f63302.

No new non-duplicate actionable finding or inline comment survived the full review and three convergence rounds. Mechanisms rediscovered during convergence were suppressed under strict root-cause deduplication; the existing inline discussions remain the source of truth.

Checkpoint conclusions:

  • Intended behavior and proof: the patch consistently hardens FileScannerV2 empty/error handling, semantic COUNT transport and safe row fallback, complex predicate localization, unsupported Parquet projections, COUNT-star placeholders, hybrid-reader state, and bounded cross-reader page-range discovery. The changed tests cover the principal local contracts; known end-to-end coverage gaps are already raised inline.
  • Scope and focus: all 55 changed files belong to those FE/BE/reader/test contracts. The supplied focus file adds no extra focus, and no unrelated production behavior was found.
  • Concurrency, lifecycle, and memory safety: shared Parquet range-directory/index state is bounded and mutex-protected with no inverse lock order found; scanner/TableReader state is split-local and reset/delegated across prepare, abort, close, and hybrid children. No distinct stale-byte, ownership, buffer-boundary, use-after-free, or initialization-order issue survived deduplication.
  • Configuration and compatibility: no new configuration or dynamic-update contract is introduced. The optional FE/BE COUNT field is conservative on a new BE receiving an old-FE plan; the remaining mixed-version capability limitation is already covered by existing inline feedback.
  • Parallel and conditional paths: V1/V2, Hive/Iceberg/Paimon/Hudi/TVF, Parquet/ORC/Native/text/JNI, table/file metadata, deletes, runtime filters, primitive/complex projections, and metadata/row fallbacks were compared. New conditions correspond to concrete semantic proofs, and unsafe cases fall back or fail explicitly subject only to existing discussions.
  • Tests and results: every changed unit/regression hunk, generated output, and fixture intent was reviewed for reachability and expected behavior. No local build or test was run, as required by the review bundle.
  • Errors and observability: changed statuses are propagated or deliberately classified; stop EOF remains separate from valid empty input, and existing scan/cache profiles plus EmptyFileNum remain connected. No separate high-value diagnostic gap was found.
  • Persistence and writes: no transaction, EditLog/replay, durable metadata, data mutation, atomic-write, or crash-recovery path is modified.
  • FE/BE variable passing: COUNT arguments are captured as ExprIds, preserved by physical-plan copies, translated to scan SlotIds, serialized in the common file-scan path, consumed by both scanners, mapped to V2 GlobalIndices, and forwarded into hybrid readers. No distinct sender/consumer omission survived.
  • Performance and other correctness: metadata COUNT and placeholder suppression avoid work only after semantic safety checks; adaptive sizing remains active for row fallbacks; cache metadata is bounded. No new non-duplicate correctness, lifecycle, memory-safety, compatibility, or material performance issue remained.

Validation was static because the review contract prohibited worktree setup and builds; .worktree_initialized and thirdparty/installed are absent. At submission time, compile, Cloud UT, vault regression, formatting, checkstyle, license, dependency, secret, and large-file checks were green. FE/BE UT and several regression/performance jobs were still pending. The macOS BE UT job failed during environment setup because Java 25 was selected while Doris requires Java 17, before project tests ran.

@hello-stephen

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

query5	4329	648	491	491
query6	467	219	223	219
query7	4843	588	351	351
query8	333	186	165	165
query9	8788	4072	4069	4069
query10	488	365	313	313
query11	5895	2312	2143	2143
query12	156	104	106	104
query13	1257	569	432	432
query14	6253	5245	4911	4911
query14_1	4278	4273	4244	4244
query15	217	208	178	178
query16	1003	481	490	481
query17	1126	724	575	575
query18	2500	484	355	355
query19	216	192	150	150
query20	113	108	113	108
query21	242	160	140	140
query22	13523	13462	13430	13430
query23	17375	16455	16212	16212
query23_1	16273	16296	16283	16283
query24	7445	1751	1284	1284
query24_1	1325	1276	1297	1276
query25	576	464	383	383
query26	1361	359	214	214
query27	2563	596	365	365
query28	4444	1993	1968	1968
query29	1075	645	504	504
query30	339	259	231	231
query31	1116	1089	978	978
query32	110	66	63	63
query33	518	353	256	256
query34	1162	1127	642	642
query35	771	773	667	667
query36	1213	1223	1092	1092
query37	162	108	102	102
query38	1893	1707	1700	1700
query39	866	861	839	839
query39_1	830	826	845	826
query40	247	168	135	135
query41	65	64	63	63
query42	91	92	90	90
query43	321	325	282	282
query44	1417	752	759	752
query45	194	184	172	172
query46	1052	1211	731	731
query47	2157	2155	2009	2009
query48	398	418	288	288
query49	585	443	309	309
query50	1081	410	339	339
query51	10717	10599	10798	10599
query52	86	85	77	77
query53	262	276	199	199
query54	300	235	216	216
query55	73	70	70	70
query56	297	278	287	278
query57	1321	1302	1223	1223
query58	287	259	286	259
query59	1577	1639	1390	1390
query60	306	278	254	254
query61	152	149	150	149
query62	546	493	442	442
query63	244	197	208	197
query64	2851	1059	839	839
query65	4719	4615	4619	4615
query66	1858	490	378	378
query67	29141	28481	28913	28481
query68	3059	1629	975	975
query69	405	308	254	254
query70	1086	934	978	934
query71	377	332	342	332
query72	3052	2692	2349	2349
query73	859	793	414	414
query74	5055	4941	4716	4716
query75	2504	2473	2145	2145
query76	2334	1171	768	768
query77	336	371	266	266
query78	12040	11863	11350	11350
query79	1366	1191	750	750
query80	1325	541	457	457
query81	572	332	287	287
query82	624	152	121	121
query83	361	335	291	291
query84	295	163	131	131
query85	981	605	525	525
query86	418	304	277	277
query87	1831	1812	1740	1740
query88	3663	2759	2751	2751
query89	425	377	320	320
query90	1908	193	198	193
query91	205	187	160	160
query92	61	61	53	53
query93	1710	1509	1030	1030
query94	714	353	312	312
query95	791	499	559	499
query96	1030	777	337	337
query97	2678	2648	2519	2519
query98	208	207	199	199
query99	1097	1108	976	976
Total cold run time: 263524 ms
Total hot run time: 177433 ms

@hello-stephen

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

query1	0.00	0.01	0.01
query2	0.09	0.05	0.05
query3	0.25	0.14	0.14
query4	1.60	0.14	0.15
query5	0.23	0.24	0.22
query6	1.28	1.02	1.02
query7	0.04	0.01	0.01
query8	0.06	0.03	0.03
query9	0.37	0.31	0.32
query10	0.55	0.54	0.54
query11	0.18	0.14	0.14
query12	0.18	0.14	0.14
query13	0.46	0.46	0.47
query14	0.99	1.01	0.99
query15	0.61	0.59	0.59
query16	0.32	0.33	0.31
query17	1.13	1.08	1.08
query18	0.23	0.22	0.20
query19	2.06	2.00	1.96
query20	0.02	0.01	0.01
query21	15.43	0.19	0.16
query22	4.95	0.06	0.05
query23	16.13	0.31	0.11
query24	2.97	0.42	0.31
query25	0.12	0.04	0.05
query26	0.74	0.20	0.16
query27	0.04	0.04	0.03
query28	3.48	0.95	0.55
query29	12.54	4.17	3.29
query30	0.28	0.15	0.16
query31	2.76	0.60	0.32
query32	3.22	0.59	0.49
query33	3.26	3.26	3.24
query34	15.46	4.18	3.54
query35	3.49	3.51	3.53
query36	0.56	0.43	0.44
query37	0.09	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.02	0.02
query40	0.18	0.17	0.16
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.61 s
Total hot run time: 25.11 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.

2 participants