lll-hhh opened a new pull request, #55718:
URL: https://github.com/apache/arrow/pull/55718

   ### Rationale for this change
   
   Fixes #43115.
   
   `ChunkedStructArrayBuilder` reconstructed output fields from only their 
names and converted child types. That reset every explicit field's nullability 
to the default (`nullable=true`), including fields nested inside structs. The 
resulting Arrow table no longer matched the schema supplied through 
`ParseOptions::explicit_schema`, which can fail downstream validation when the 
table is written.
   
   ### What changes are included in this PR?
   
   - Carry each declared child field's nullability into 
`ChunkedStructArrayBuilder` instead of discarding it.
   - Apply the retained nullability when constructing the output struct type.
   - Use the inferred field's nullability when an unexpected field is promoted, 
preserving the existing inference path.
   - Add a regression covering both required and optional top-level fields and 
required and optional fields in a nested struct.
   
   ### Are these changes tested?
   
   Yes, against an editable Arrow C++ 27.0.0/SNAPSHOT and PyArrow build in WSL.
   
   - The new regression fails on the unmodified base and passes with the change 
in both serial and parallel readers: `2 passed`.
   - `python -m pytest pyarrow/tests/test_json.py -q`: `84 passed, 2 skipped`.
   - Arrow C++ shared build and install completed successfully.
   - `clang-format==18.1.8 --dry-run --Werror`, `flake8` with 
`python/setup.cfg`, and `autopep8 --diff` passed on the modified files.
   
   ### Are there any user-facing changes?
   
   Yes. JSON tables created with an explicit schema now retain the declared 
nullability of top-level and nested struct fields instead of silently replacing 
it with `nullable=true`. Data and types are otherwise unchanged.
   
   ### Was AI used for this PR?
   
   In accordance to the AI generation guidelines, AI was used for 
implementation, tests, and description. The behavior was reproduced against the 
unmodified base, reviewed, and validated against a local Arrow build before 
submission.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [x] AI
   - [ ] Not reviewed
   
   * GitHub Issue: #43115
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to