Repository navigation
perf: read only the nested fields Spark keeps in the native Iceberg scan #6725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andygrove
merged 9 commits into
apache:main
from
comphead:iceberg-nested-schema-pruning
Oct 16, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4125e42
perf: read only the nested fields Spark keeps in the native Iceberg scan
comphead 335e7e0
feedback
comphead d88698c
Resolve appended task-schema columns from one schema
comphead 6213d05
Build one task schema per scan for native Iceberg reads
comphead 8566834
Check the full task schema for nested evolution
comphead 5395e50
Check the task schema the scan reads for nested evolution
comphead 86eaa60
Match field types when picking the full task schema
comphead 170e5eb
Fix the native Iceberg task schema at planning
comphead 7d8138a
Simplify the native Iceberg task schema code and tests
comphead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] [P2] Validate the historical full task schema for nested evolution. Create
t(id INT, c INT, s STRUCT<k: STRING, a: INT>) USING iceberg PARTITIONED BY (s.k), write a file, adds.b INT, write another file, and record snapshot S. Then dropcands.b.SELECT id, c, s.a FROM t VERSION AS OF Sselects a historical full schema containings.b, becausecis historical and the unprojected nested partition sources.kprevents pruning. However,CometScanRulechecks onlymetadata.tableSchemaandmetadata.scanSchema, neither of which containss.b. Native execution consequently fails reading the older file withIncorrect number of arrays for StructArray fields, expected 3 got 2, while Spark and the base schema succeed. Both pruning settings select this unsafe full schema. Could the planning guard validatemetadata.fullTaskSchemaas well and fall back for this case?Evidence: Fresh reproduction in
/tmp/pr6725-6213-review-oct12-c2z7stms/:NestedHistoryProbe.scalawrites(1,100,{k:east,a:10}), addss.b, writes(2,200,{k:east,a:20,b:99}), records S, then dropscands.b. Spark 4.1.3/Iceberg 1.11.0 returns[1,100,10]and[2,200,20]. The exact-head helpers produceprunedTaskSchema=None; the current guard reports no changes, whereas checking the selected full schema reportss.b (added). Reading those same files with pinned iceberg-rustaf1da4c5bc86178c38c1c6db0578bdd9fb7021e3reportsBASE: SUCCESS rows=2andHEAD: ERROR ... expected 3 got 2. The base augmentation helper also matches the currentbranch-1.1implementation. Sources, generated schemas, and logs are preserved in that directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this table through Comet. At 6213d05,
SELECT id, c, s.a FROM t VERSION AS OF Sfailed natively with pruning on and off. An unpartitioned variant also failed with pruning off:t(id INT, c INT, s STRUCT<a: INT>), adds.b, write a second file, take snapshotS, then dropcands.b. At 8566834 both now fall back and match Spark. I left a related question on the new check inCometScanRule.scala.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed from the code, thanks. Since 6213d05 the full task schema can be older than the table's, and the nested-evolution check walked only the table and scan schemas. 8566834 adds the full task schema to that check, so your read falls back to Spark with
s.b (added)instead of failing in the native scan. The struct fallback test now has your table. Keeping this case native would need the nested partition source merged back into its pruned struct, which I'd leave for a follow-up.