apache / apache/parquet-java

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

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

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in parquet-column/src/main/java/org/apache/parquet/io/MessageColumnIO.java intorno alle righe 97-99 e verifica come viene selezionato EmptyRecordReader quando nel file fisico non esistono colonne foglia dello schema richiesto. Riproduci il caso S1-to-S2 e verifica che la lettura del record produca n con c e d impostati a null, invece di impostare n a null.

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à
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.