feat(arrow): Support reading nested parquet columns #2001
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.
Which issue does this PR close?
What changes are included in this PR?
This PR enables projection of nested fields within struct columns when reading parquet files. Previously, selecting a field nested inside a struct would result in a
FeatureUnsupportederror.Problem
When users try to select nested fields like
person.namefrom a schema such as:The scan would fail with "Projecting nested field is not supported now" error, blocking access to nested column data.
Solution
1.
crates/iceberg/src/arrow/reader.rsRecordBatchProjectorintegration to detect and handle nested field projectionsRecordBatchProjectorto extract nested fields from their parent structs, flattening them into the output record batch_file) from nested field detection2.
crates/iceberg/src/arrow/record_batch_transformer.rsbuild_field_id_to_arrow_schema_mapto recursively index nested struct fieldscollect_field_ids_recursiveto traverse the field hierarchy3.
crates/iceberg/src/scan/mod.rsFeatureUnsupportederror)How it works
FileScanTask, detect if any requested field IDs are nested by checking ifschema.as_struct().field_by_id(id)returnsNoneRecordBatchProjectorwith the projected arrow schema[1, 0]means column 1, inner field 0)Are these changes tested?
Yes, added
test_read_nested_parquet_columntest that:id,person { name, age })[1, 3](selectingidand nestedname)