Skip to content

[fix](iceberg) Project Iceberg system table scans#65262

Open
suxiaogang223 wants to merge 1 commit into
apache:masterfrom
suxiaogang223:codex/iceberg-system-table-projection
Open

[fix](iceberg) Project Iceberg system table scans#65262
suxiaogang223 wants to merge 1 commit into
apache:masterfrom
suxiaogang223:codex/iceberg-system-table-projection

Conversation

@suxiaogang223

Copy link
Copy Markdown
Member

What problem does this PR solve?

Iceberg system table scans serialize Iceberg SDK FileScanTask objects and the Java metadata scanner materializes rows from the task schema. Doris did not pass the actually required system table columns into the Iceberg SDK scan, so metadata tables such as $files and $data_files were planned with the full schema. For files metadata tables, the full schema can include virtual readable_metrics even when the SQL only requests columns such as file_size_in_bytes.

This PR applies SDK top-level column projection only for Iceberg system table scans. Normal Iceberg data table scans continue to rely on Doris BE scan range params for column pruning.

What changed?

  • Add system-table-only TableScan.select(...) projection in IcebergScanNode before planning the Iceberg SDK scan.
  • Skip synthesized/global row id and Iceberg row lineage columns when building the SDK projection list.
  • Add regression coverage for ORC and Parquet Iceberg tables with map<boolean, boolean> columns, verifying projected $data_files and $files queries.

Check List (For Author)

  • Test: Build
    • DISABLE_BUILD_UI=ON MAVEN_OPTS='-Xmx8g' FE_MAVEN_THREADS=1 FE_MAVEN_RETRY_THREADS=1 ./build.sh --fe
  • 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?

@suxiaogang223 suxiaogang223 marked this pull request as ready for review July 6, 2026 09:48
@suxiaogang223

Copy link
Copy Markdown
Member Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor

what will happen if read_metrics is requested by users? Please add regression tests to prove it

@Gabriel39

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 completed for PR 65262.

I did not find a substantiated correctness issue to raise as an inline comment.

Critical checkpoint conclusions:

  • Goal and tests: the change projects required top-level columns only for Iceberg system table scans before SDK planning, while normal Iceberg data-table scans keep the existing BE scan-range pruning path. The added external regression covers $data_files and $files projected queries for ORC and Parquet tables containing map<boolean, boolean>.
  • Scope: the code change is narrow and localized to IcebergScanNode.createTableScan() plus the helper used to build the system-table projection list.
  • Concurrency/lifecycle: no new shared mutable lifecycle or lock-sensitive path was introduced. The scan still plans system-table splits through the existing synchronous system-table path and caches the planned scan as before.
  • Compatibility/config/session: no new config, persisted format, FE-BE protocol field, or rolling-upgrade-sensitive thrift field was added. The existing JNI scanner required-field contract remains name based.
  • Parallel paths: normal Iceberg table scans are intentionally not changed; system-table scans are the path where Iceberg SDK DataTask materializes metadata rows from the serialized FileScanTask schema.
  • Test/output coverage: the test uses existing external Iceberg suite patterns with direct SQL result assertions for nondeterministic file sizes and orders result sets where needed. No .out file is required for these assertion-only checks.
  • Validation limits: this runner checkout is grafted/shallow with no parent commit, .worktree_initialized is missing, and thirdparty/installed/bin/protoc is unavailable, so I could not run the FE build or regression suite locally. I did run static PR-scope checks against the GitHub patch for changed-file scope and whitespace/CRLF issues.

User focus: no additional user-provided review focus was supplied.

Subagent conclusions:

  • optimizer-rewrite: no candidates in the initial pass; convergence round 1 returned NO_NEW_VALUABLE_FINDINGS.
  • tests-session-config: no candidates in the initial pass; convergence round 1 returned NO_NEW_VALUABLE_FINDINGS.
  • No candidates were accepted, dismissed, or merged as duplicates, and the final inline comment set is empty.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/16) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Iceberg system table scans serialize SDK FileScanTask objects and the Java metadata scanner materializes rows from DataTask rows. Doris did not pass the actually required system table columns into the Iceberg SDK scan, so metadata tables such as files and data_files were planned with the full schema. For files metadata tables this can include virtual readable_metrics even when the query only requests columns such as file_size_in_bytes. The original select-based projection is also not enough because Iceberg DataTask implementations expose schema differently: manifest-backed tasks expose the projected schema, while StaticDataTask exposes the full schema even though rows are projected. Use an explicit SDK projected Schema whose prefix matches Doris required columns, append filter-only columns after that prefix, and make the JNI reader read projected rows by required ordinal while using the task schema only for field type lookup. Add regression coverage for ORC and Parquet projected files/data_files queries and for explicitly requested readable_metrics.

### Release note

None

### Check List (For Author)

- Test: Build
    - DISABLE_BUILD_UI=ON ./build.sh --fe
- Behavior changed: No
- Does this need documentation: No
@suxiaogang223 suxiaogang223 force-pushed the codex/iceberg-system-table-projection branch from 0dd8b91 to b4a9dcb Compare July 7, 2026 07:03
@suxiaogang223

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17668	3974	3976	3974
q2	2042	322	197	197
q3	10351	1410	812	812
q4	4691	465	336	336
q5	7512	872	581	581
q6	179	171	140	140
q7	787	872	636	636
q8	9344	1517	1602	1517
q9	5721	4417	4414	4414
q10	6762	1794	1547	1547
q11	505	355	316	316
q12	715	555	433	433
q13	18112	3448	2795	2795
q14	268	263	238	238
q15	q16	804	780	720	720
q17	917	935	1044	935
q18	6940	5919	5693	5693
q19	1298	1200	1081	1081
q20	782	645	566	566
q21	5970	2621	2406	2406
q22	431	360	303	303
Total cold run time: 101799 ms
Total hot run time: 29640 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4355	4329	4268	4268
q2	304	344	235	235
q3	4557	5158	4478	4478
q4	2065	2146	1359	1359
q5	4465	4324	4321	4321
q6	230	173	127	127
q7	1760	2033	1910	1910
q8	2583	2272	2185	2185
q9	8134	8241	7819	7819
q10	4762	4728	4267	4267
q11	580	437	400	400
q12	771	784	574	574
q13	3246	3605	2923	2923
q14	306	320	298	298
q15	q16	700	726	662	662
q17	1384	1369	1371	1369
q18	8095	7388	7385	7385
q19	1155	1112	1075	1075
q20	2201	2210	1950	1950
q21	5316	4631	4478	4478
q22	508	479	405	405
Total cold run time: 57477 ms
Total hot run time: 52488 ms

@hello-stephen

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

query5	4334	643	483	483
query6	462	217	209	209
query7	4890	602	356	356
query8	347	197	173	173
query9	8749	4034	4018	4018
query10	474	357	280	280
query11	5935	2366	2191	2191
query12	164	103	99	99
query13	1247	586	444	444
query14	6285	5279	4985	4985
query14_1	4288	4304	4289	4289
query15	215	203	184	184
query16	1061	484	475	475
query17	1146	720	583	583
query18	2464	482	354	354
query19	219	197	155	155
query20	123	111	108	108
query21	232	162	134	134
query22	13647	13709	13436	13436
query23	17421	16599	16234	16234
query23_1	16356	16248	16294	16248
query24	7513	1787	1329	1329
query24_1	1319	1315	1283	1283
query25	591	460	398	398
query26	1331	358	221	221
query27	2587	631	379	379
query28	4510	2012	2009	2009
query29	1082	634	501	501
query30	338	266	224	224
query31	1124	1107	993	993
query32	160	62	61	61
query33	535	330	262	262
query34	1187	1147	612	612
query35	775	788	685	685
query36	1433	1392	1272	1272
query37	162	109	93	93
query38	1901	1720	1652	1652
query39	936	910	937	910
query39_1	890	875	893	875
query40	253	161	140	140
query41	68	62	61	61
query42	89	91	92	91
query43	317	320	277	277
query44	1415	784	767	767
query45	205	187	178	178
query46	1036	1173	757	757
query47	2360	2367	2281	2281
query48	393	422	301	301
query49	591	439	336	336
query50	1002	409	320	320
query51	10936	10791	10566	10566
query52	86	87	73	73
query53	263	292	202	202
query54	279	228	241	228
query55	73	74	65	65
query56	300	278	272	272
query57	1444	1412	1322	1322
query58	301	257	252	252
query59	1569	1617	1395	1395
query60	317	269	246	246
query61	154	148	157	148
query62	700	650	598	598
query63	246	211	203	203
query64	2573	782	599	599
query65	4864	4758	4766	4758
query66	1821	528	388	388
query67	29615	29448	29300	29300
query68	3258	1548	960	960
query69	428	315	268	268
query70	1081	1004	940	940
query71	348	315	306	306
query72	2976	2627	2326	2326
query73	869	796	454	454
query74	5148	4967	4764	4764
query75	2638	2568	2229	2229
query76	2318	1161	797	797
query77	359	385	285	285
query78	12468	12295	11799	11799
query79	1448	1172	786	786
query80	1296	533	469	469
query81	526	324	274	274
query82	1222	155	119	119
query83	374	322	286	286
query84	299	154	128	128
query85	964	601	508	508
query86	492	295	294	294
query87	1834	1816	1731	1731
query88	3702	2767	2754	2754
query89	472	400	366	366
query90	1933	194	198	194
query91	202	190	167	167
query92	66	63	57	57
query93	1673	1588	972	972
query94	777	355	307	307
query95	781	570	472	472
query96	1080	782	387	387
query97	2706	2669	2560	2560
query98	213	203	197	197
query99	1198	1164	1031	1031
Total cold run time: 267237 ms
Total hot run time: 179899 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.10	0.07	0.05
query3	0.26	0.13	0.14
query4	1.61	0.15	0.13
query5	0.25	0.22	0.22
query6	1.26	1.05	1.04
query7	0.04	0.00	0.00
query8	0.06	0.04	0.04
query9	0.39	0.34	0.31
query10	0.55	0.56	0.56
query11	0.19	0.15	0.14
query12	0.18	0.14	0.14
query13	0.48	0.48	0.48
query14	1.01	1.01	1.01
query15	0.62	0.61	0.60
query16	0.32	0.33	0.30
query17	1.06	1.07	1.09
query18	0.22	0.21	0.20
query19	2.03	1.95	1.97
query20	0.02	0.01	0.01
query21	15.42	0.22	0.14
query22	4.72	0.05	0.05
query23	16.20	0.32	0.12
query24	3.02	0.44	0.30
query25	0.11	0.07	0.04
query26	0.73	0.21	0.14
query27	0.03	0.03	0.04
query28	3.52	0.92	0.54
query29	12.58	4.08	3.22
query30	0.28	0.16	0.15
query31	2.77	0.62	0.31
query32	3.22	0.59	0.48
query33	3.24	3.22	3.17
query34	15.60	4.25	3.55
query35	3.54	3.52	3.53
query36	0.55	0.45	0.42
query37	0.09	0.07	0.06
query38	0.04	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.16
query41	0.08	0.03	0.03
query42	0.04	0.02	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.7 s
Total hot run time: 24.93 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants