apache / apache/parquet-java

Variant field names not being ordered correctly via UTF-8 byte order

Đang mở
#3,735 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
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ả

### Describe the bug, including details regarding any error messages, version, and platform.

The Variant spec requires the field ids in an object's header to be sorted by the
**UTF-8 byte order** of the field names, so a reader can binary-search them.
`VariantBuilder` sorted the fields — and `Variant.getFieldByKey` binary-searched them —
using `String.compareTo`, which orders by **UTF-16 code units**, not UTF-8 bytes.

The two orderings are identical for all field names in the Basic Multilingual Plane, but
they diverge for names containing supplementary-plane characters (U+10000 and above):
`String.compareTo` orders a leading high surrogate (0xD800–0xDBFF) before code points in
U+E000..U+FFFF, whereas UTF-8 byte order (and the spec) orders them after. Consequences:

- An object parquet-java builds with such keys has field ids sorted in an order that
violates the spec.
- A spec-compliant reader (e.g. the Apache Arrow C++/Rust/Go Variant readers) binary-searching
that object can fail to find fields.
- Conversely, parquet-java's own binary search fails to find a supplementary-plane key in an
object produced by a spec-compliant writer.

The bug only surfaces when an object both contains a supplementary-plane key and is large
enough to take the binary-search path, so it has gone unnoticed.

### Component(s)
Core

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 với VariantBuilder và Variant.getFieldByKey, sau đó tái hiện vấn đề bằng một đối tượng có tên trường thuộc supplementary plane và đủ trường để kích hoạt tìm kiếm nhị phân. Xác minh rằng các ID trường tuân theo thứ tự byte UTF-8 và việc tra cứu thành công đối với các đối tượng được tạo bởi cả parquet-java và các writers tuân thủ đặc tả.

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
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
68/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.