Extract shared ParquetReadPlan for leaf column resolution#20913
Extract shared ParquetReadPlan for leaf column resolution#20913friendlymatthew wants to merge 2 commits intoapache:mainfrom
ParquetReadPlan for leaf column resolution#20913Conversation
9e7475e to
c59c746
Compare
c59c746 to
8499b91
Compare
adriangb
left a comment
There was a problem hiding this comment.
I take it the idea is that this can be re-used for the projection side of things because it was written in a reusable manner, even thought at the moment it is only used for the row filter?
I generally like this change :)
| || self.is_nested_type_supported(return_type) | ||
| { | ||
| // try to resolve all field name arguments to strinrg literals | ||
| // if any argument is not a string literal, we can not determine the exact |
There was a problem hiding this comment.
Under what circumstances would get_field accept non-string literal arguments? Would this be a column e.g. get_field(struct_col, fields_col)?
There was a problem hiding this comment.
In practice, get_field will always receive string literals. This is enforced at different levels:
- At runtime, the udf requires all field_name args to be scalars
- At planning time, field names must be non-empty strings
The None fallback is purely defensive. It's not likely that we'll hit this in practice, but in the case we do, we'll just read out the entire struct. Though, we can also err here like we did before
There was a problem hiding this comment.
I think we need to either:
- Do something slower but correct (read out entire struct)
- Error explicitly
Since we are doing one of these I think it's good for now 👍🏻
Yes exactly. Here's a PR that does exactly just that! #20925 |
Note: please review from the second commit. This PR is currently based off of #20854
Rationale for this change
This PR extracts a reusable
build_parquet_read_planfunction andParquetReadPlanstruct from the row filter'sFilterCandidateBuilder::buildToday, struct-aware leaf projection only exists in the row filter path. The opener still uses
ProjectionMask::rootswhich reads all leaves of a struct even when only one field is needed. By pulling this logic into a shared abstraction, the opener can reduce unnecessary I/O for struct-heavy schemas