apache / apache/parquet-java

Exception thrown by AvroParquetWriter#write causes all subsequent calls to it to fail

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

Descrizione

Please see sample code below:
```java

Schema schema = new Schema.Parser().parse("""
{
"type": "record",
"name": "person",
"fields": [
{
"name": "address",
"type": [
"null",
{
"type": "array",
"items": "string"
}
],
"default": null
}
]
}
"""
);

ParquetWriter writer = AvroParquetWriter.builder(new org.apache.hadoop.fs.Path("/tmp/person.parquet"))
.withSchema(schema)
.build();

try {
// To trigger exception, add array with null element.
writer.write(new GenericRecordBuilder(schema).set("address", Arrays.asList("first", null, "last")).build());
} catch (Exception e) {
e.printStackTrace(); // "java.lang.NullPointerException: Array contains a null element at 1"
}

try {
// At this point all future calls to writer.write will fail
writer.write(new GenericRecordBuilder(schema).set("address", Arrays.asList("foo", "bar")).build());
} catch (Exception e) {
e.printStackTrace(); // "org.apache.parquet.io.InvalidRecordException: 1(r) > 0 ( schema r)"
}

writer.close();
```
It seems to me this is caused by state not being reset between writes. Is this the indented behavior of the writer? And if so, does one have to create a new writer whenever a write fails?

I'm able to reproduce this using both parquet 1.8.3 and 1.11.0, and have attached a sample parquet file for each version.

**Reporter**: [Øyvind Strømmen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=InsulaVentus)
#### Original Issue Attachments:
- [person1_11_0.parquet](https://issues.apache.org/jira/secure/attachment/13008167/person1_11_0.parquet)
- [person1_8_3.parquet](https://issues.apache.org/jira/secure/attachment/13008168/person1_8_3.parquet)

**Note**: *This issue was originally created as [PARQUET-1887](https://issues.apache.org/jira/browse/PARQUET-1887). 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 dal punto di ingresso AvroParquetWriter#write ed esegui la riproduzione fornita con le versioni di Parquet interessate. Traccia lo stato di ParquetWriter dopo che l'array contenente null ha causato un'eccezione, quindi determina e testa il comportamento previsto per una successiva scrittura valida; il lavoro è completato quando tale comportamento è stato stabilito in modo affidabile.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.