test(spark): add nested schema pruning coverage - #19406
Draft
yihua wants to merge 1 commit into
Draft
Conversation
Extend TestNestedSchemaPruningOptimization to cover the previously untested branches of HoodieNestedSchemaPruning (around 30 percent line coverage): - Prune a nested struct when array<struct> and map<string,struct> columns are also present, exercising the array and map branches of countLeaves and the full successful-pruning path (getPrunedOutput, buildNewProjection, buildPrunedRelation). - No-op when every nested sub-field is selected, so the pruned schema has the same leaf count as the data schema. - No-op when the nested schema pruning optimizer flag is disabled. Factor the plan-level schema assertion shared with the existing successful test into a single helper.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19406 +/- ##
============================================
+ Coverage 74.83% 74.89% +0.06%
- Complexity 32332 32369 +37
============================================
Files 2574 2574
Lines 142978 142984 +6
Branches 17527 17536 +9
============================================
+ Hits 106992 107086 +94
+ Misses 27921 27832 -89
- Partials 8065 8066 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Collaborator
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe the issue this Pull Request addresses
HoodieNestedSchemaPruning, the Catalyst optimizer rule that prunes nested (struct) schemas for Hudi relations, sat at roughly 30 percent line coverage.TestNestedSchemaPruningOptimizationonly exercised a single-nested-struct table, leaving several branches of the rule untested: the array and map cases ofcountLeaves, the successful-pruning path (getPrunedOutput/buildNewProjection/buildPrunedRelation), the no-op when the pruned schema has the same leaf count as the data schema, and the no-op when the optimizer flag is off.Summary and Changelog
Test-only change. Extends
TestNestedSchemaPruningOptimizationwith three cases that assert the optimized plan's read schema, pinning the exact pruned/unpruned schema rather than just that the query returns rows:prunes nested struct when array and map columns are present: a MOR table withitem struct<...>,tags array<struct<...>>, andprops map<string, struct<...>>; projectingid, item.nameprunesitemdown tonameand drops the unreferenced complex columns. BecausecountLeavesis called on the full data schema, this exercises itsArrayTypeandMapTypebranches along with the whole successful-pruning path.no-op when all nested sub-fields are selected: selecting every leaf keepsitemasstruct<name, price>(the leaf-count comparison is an equality, so the rule does not rewrite).no-op when nested schema pruning is disabled: withspark.sql.optimizer.nestedSchemaPruning.enabled=falsethe rule short-circuits anditemretainspriceeven though onlyitem.nameis projected.The plan-level schema assertion that the existing successful test performed inline is factored into a shared
assertPrunedReadSchemahelper used by both.Impact
None. Adds test coverage only, no production code changes.
Risk Level
none
Documentation Update
none
Contributor's checklist