yihua opened a new pull request, #19406: URL: https://github.com/apache/hudi/pull/19406
### 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. `TestNestedSchemaPruningOptimization` only exercised a single-nested-struct table, leaving several branches of the rule untested: the array and map cases of `countLeaves`, 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 `TestNestedSchemaPruningOptimization` with 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 with `item struct<...>`, `tags array<struct<...>>`, and `props map<string, struct<...>>`; projecting `id, item.name` prunes `item` down to `name` and drops the unreferenced complex columns. Because `countLeaves` is called on the full data schema, this exercises its `ArrayType` and `MapType` branches along with the whole successful-pruning path. - `no-op when all nested sub-fields are selected`: selecting every leaf keeps `item` as `struct<name, price>` (the leaf-count comparison is an equality, so the rule does not rewrite). - `no-op when nested schema pruning is disabled`: with `spark.sql.optimizer.nestedSchemaPruning.enabled=false` the rule short-circuits and `item` retains `price` even though only `item.name` is projected. The plan-level schema assertion that the existing successful test performed inline is factored into a shared `assertPrunedReadSchema` helper used by both. ### Impact None. Adds test coverage only, no production code changes. ### Risk Level none ### Documentation Update none ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
