apache / apache/parquet-java

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

Aperta
#3,735 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Type: bug
Lingua principale
Java
Stelle
3.1k
Fork
1.6k
Merge medio
3g 12h
PR unite (30g)
33

Descrizione

### 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia con VariantBuilder e Variant.getFieldByKey, quindi riproduci il problema usando un oggetto con un nome di campo del piano supplementare e un numero sufficiente di campi per attivare la ricerca binaria. Verifica che gli ID dei campi seguano l’ordine dei byte UTF-8 e che la ricerca abbia esito positivo per gli oggetti prodotti sia da parquet-java sia da writers conformi alla specifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
data-engineering
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.