apache / apache/parquet-java

ProtoSchemaConverter renders invalid schema for oneof in unwrap mode

Aperta
#3,039 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.

When unwrap is enabled all fields of the `TestProto3.OneOfTestMessage` will be required.

```
message TestProto3.OneOfTestMessage {
required int32 first = 1;
required int32 second = 2;
}
```
https://github.com/apache/parquet-java/blob/73a4430af6c40f8eb246ad4911eb6d103c9a2abe/parquet-protobuf/src/test/resources/TestProto3.proto#L116

This will never work but tests are missing for unwrap of `TestProto3.OneOfTestMessage`

The required repetition is added here:
https://github.com/apache/parquet-java/blob/73a4430af6c40f8eb246ad4911eb6d103c9a2abe/parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoSchemaConverter.java#L278

This could be caught early by adding `withValidation(true)` here:
https://github.com/apache/parquet-java/blob/73a4430af6c40f8eb246ad4911eb6d103c9a2abe/parquet-protobuf/src/test/java/org/apache/parquet/proto/TestUtils.java#L221

If validation is disabled it will fail when trying to read one of the non-existing fields in the `oneof`.

Is there really a need for setting all primitive fields in unwrap to required?

### Component(s)

_No response_

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoSchemaConverter.java, nella gestione di unwrap repetition, quindi esamina il fixture TestProto3.OneOfTestMessage e i relativi test. Abilita la validazione in parquet-protobuf/src/test/java/org/apache/parquet/proto/TestUtils.java e aggiungi la copertura per il unwrap mode. Il lavoro è completato quando la conversione di oneof produce uno schema valido e il read path pertinente è testato.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.