pyarrow.json.read_json ignores nullable=True on fields with non-nullable subfields in explicit_schema parse_options
- Lingua principale
- C++
- Stelle
- 17.1k
- Fork
- 4.3k
- Merge medio
- 3g 23h
- PR unite (30g)
- 101
Descrizione
**Summary:**
The parser seems to be ignoring the "nullable" flag on the parent field.
This behavior may be related to ARROW-16603, but that issue covers the opposite case - failing to include the "not null" constraints in the schema of the output table.
**Reproducible example:**
```java
import pyarrow as pa
interior_struct = pa.struct([
pa.field(name='some_information', type=pa.int64(), nullable=False)
])
sample_schema = pa.schema([
pa.field(name='my_struct', type=interior_struct, nullable=True)
])
# The issue persists regardless of the input JSON,
# so long as there is no field named "my_struct" in the input.
# Using an empty JSON object for example
sample_json_bytes = io.BytesIO('{}'.encode())
table = pa.json.read_json(
input_file=sample_json_bytes,
parse_options=pa.json.ParseOptions(explicit_schema=sample_schema)
)
print(table)
```
**Expected output:**
Table containing one column:
- Name is "my_struct"
- Type is "interior_struct"
- Contains a single value, which is null
**Actual output:**
```java
ArrowInvalid: JSON parse error: a required field was null
```
**Reporter**: [Ryan Weisman](https://issues.apache.org/jira/browse/ARROW-17835)
**Note**: *This issue was originally created as [ARROW-17835](https://issues.apache.org/jira/browse/ARROW-17835). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo il problema tramite pyarrow.json.read_json con ParseOptions(explicit_schema=sample_schema) e un oggetto JSON vuoto. Traccia come viene gestito lo schema esplicito quando il campo padre è nullable, ma il relativo campo annidato non è nullable, quindi verifica che il risultato contenga un valore null per my_struct senza un errore di campo obbligatorio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, python
- Ambito
- data-engineering
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100