apache / apache/parquet-java

Nested records are not properly read if none of their fields are requested

Đang mở
#1,885 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Component: Java Component: Parquet Priority: Major Type: bug
Ngôn ngữ chính
Java
Star
3.1k
Fork
1.6k
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
33

Mô tả

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.*

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu tại parquet-column/src/main/java/org/apache/parquet/io/MessageColumnIO.java, khoảng dòng 97-99, và kiểm tra cách EmptyRecordReader được chọn khi không tồn tại cột lá nào của schema được yêu cầu trong tệp vật lý. Tái hiện trường hợp S1-to-S2 và xác minh rằng việc đọc record tạo ra n với c và d được đặt thành null, thay vì đặt n thành null.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
data-engineering
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.