Nested records are not properly read if none of their fields are requested
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 33
Description
Say we have a Parquet file `F` with the following schema `S1`:
```
message root {
required group n {
optional int32 a;
optional int32 b;
}
}
```
Later on, as the schema evolves, fields `a` and `b` are removed, while `c` and `d` are added. Now we have schema `S2`:
```
message root {
required group n {
optional int32 c;
optional int32 d;
}
}
```
`S1` and `S2` are compatible, so it should be OK to read `F` with `S2` as requested schema.
Say `F` contains a single record:
```
{"n": {"a": 1, "b": 2}}
```
When reading `F` with `S2`, expected output should be:
```
{"n": {"c": null, "d": null}}
```
But currently parquet-mr gives
```
{"n": null}
```
This is because `MessageColumnIO` finds that the physical Parquet file contains no leaf columns defined in the requested schema, and shortcuts record reading with an `EmptyRecordReader` for column `n`. See [here](https://github.com/apache/parquet-mr/blob/apache-parquet-1.8.1/parquet-column/src/main/java/org/apache/parquet/io/MessageColumnIO.java#L97-L99).
**Reporter**: [Cheng Lian](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=lian+cheng) / @liancheng
**Note**: *This issue was originally created as [PARQUET-370](https://issues.apache.org/jira/browse/PARQUET-370). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.