Optimize Parquet row-filter struct schema pruning - #22960
Conversation
kosiew
left a comment
There was a problem hiding this comment.
Looks good overall. I left one small suggestion that may make the grouping logic a bit easier to follow.
| .iter() | ||
| .filter_map(|p| p.first().map(|s| s.as_str())) | ||
| .collect::<BTreeSet<_>>(); | ||
| let paths_by_field = paths.iter().filter_map(|path| path.split_first()).fold( |
There was a problem hiding this comment.
This grouping logic now shows up at both schema levels with similar BTreeMap<_, Vec<_>> construction. It might be worth adding a small local helper for grouping paths by their next component, so the invariant, group once per schema level and then recurse, lives in one place. I think that would also make the fold with the mutable accumulator a bit easier to scan.
There was a problem hiding this comment.
I added 2 helpers: group_access_paths_by_root and group_paths_by_next_field
kosiew
left a comment
There was a problem hiding this comment.
@shehab-ali
Thanks for the iteration.
Looks 👍 to me
|
🚀 thank you @kosiew and @shehab-ali |
Rationale for this change
build_filter_schema andprune_struct_type` repeatedly scanned the same struct-field access paths while constructing Parquet row-filter projection schemas. That caused avoidable iterator work and temporary allocations when filters referenced multiple struct fields, especially across nested struct paths.This change groups struct field access paths once per schema level, so schema pruning can reuse lookups instead of repeatedly filtering the full access-path list.
What changes are included in this PR?
Benchmark Results
These results compare each benchmark’s with_pushdown case against its matching no_pushdown case in the current code.
Throughput comparison
Are these changes tested?
Are there any user-facing changes?
No