aikhanjum opened a new pull request, #55805:
URL: https://github.com/apache/arrow/pull/55805

   ### Rationale for this change
   
   The JSON reader rejects a missing or null nullable struct when that struct 
has non-nullable children. With an explicit schema where `my_struct` is 
nullable and its child `some_information` is a non-nullable int64, reading `{}` 
or `{"my_struct": null}` fails with "JSON parse error: a required field was 
null". Each of those rows should produce one null struct.
   
   ### What changes are included in this PR?
   
   A null struct still needs placeholder slots in its child arrays so later 
rows stay aligned. `RawBuilderSet::AppendNull` appends those slots recursively, 
but it also checked each hidden child slot against the child's nullability, as 
if it were a real JSON null.
   
   This passes `parent_is_null` through that recursion so slots masked by a 
null parent can be appended. Calls for actual JSON values keep the 
required-field check, so `{"my_struct": {}}` and `{"my_struct": 
{"some_information": null}}` are still rejected. No public API changes.
   
   ### Are these changes tested?
   
   Yes. Two parser tests were added.
   
   - `BlockParserWithSchema.NullableStructWithRequiredChildren` reads null and 
missing nullable structs with required children, including a required nested 
struct with a required boolean child, then a populated row. It checks parent 
validity, the populated row's child values and full array validation.
   - `BlockParserWithSchema.RequiredChildrenOfValidStruct` checks that absent 
or null required children are still rejected after a null parent row, and that 
absent or null non-nullable parents are rejected.
   
   On upstream main dd456e00f1caf86b6c31a89a608d6f807f64f15d, macOS arm64, 
Apple Clang 17, Debug minimal preset with tests, compute, JSON and CSV enabled.
   
   - Without the parser change, both new tests fail with the reported "a 
required field was null" error.
   - With the change, both pass, and the full `arrow-json-test` binary passes 
248 tests from 60 test suites.
   - clang-format 18.1.8 on the changed lines, cpplint 1.6.1 on both files and 
`git diff --check` pass.
   
   Not run here. Python bindings, Linux, Windows, sanitizers, the full Arrow 
suite and upstream CI. This is independent of the output-schema nullability 
work in GH-31957 and the open PR for GH-43115.
   
   ### Are there any user-facing changes?
   
   Yes. Valid JSON that was rejected now reads as null structs.
   
   ### Was AI used for this PR?
   
   In accordance to the [AI generation 
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
 please disclose below whether and how AI was used in this PR.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [x] AI
   - [ ] Not reviewed
   
   OpenAI Codex searched for overlapping work, investigated the parser, wrote 
the fix and regression tests and ran the first validation. Claude Code re-ran 
the validation on current main and updated this description.
   
   * GitHub Issue: #33055
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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