ShivamSharma43 opened a new pull request, #1658:
URL: https://github.com/apache/arrow-go/pull/1658

   ### Rationale for this change
   
   Writing a record batch with a list, large list or map of dictionary values 
fails when all the lists in the batch are null or empty:
   
   ```
   unknown error type: runtime error: invalid memory address or nil pointer 
dereference
   ```
   
   `dictEncoder.PutIndices` reads the values buffer of the indices, which an 
empty array doesn't have.
   
   Once such a file can be written, reading it back gives dictionary values 
without a dictionary. `array.ValidateFull` accepts them, but printing the array 
panics with a nil dereference. `chunksToSingle` builds an array with empty 
buffers when there are no chunks, and a dictionary array also needs a 
dictionary.
   
   ### What changes are included in this PR?
   
   - `PutIndices` returns early for an empty array.
   - `chunksToSingle` uses `array.MakeArrayOfNull` for the empty array, which 
sets an empty dictionary for dictionary types.
   
   ### Are these changes tested?
   
   Yes. `TestArrowWriteNestedDictionaryWithoutValues` round-trips `[null]`, 
`[[]]` and `[null, [], null]` for `list<dictionary>` (int32 and int8 indices), 
`large_list<dictionary>` and `map<string, dictionary>`, and compares the 
printed arrays. Without the writer change all 12 cases fail with the error 
above. Without the reader change, the 8 cases with an empty list fail.
   
   On Windows amd64 with Go 1.26.9 and the pinned `parquet-testing` data, `go 
test -tags assert` passes for `./parquet/pqarrow/...`, 
`./parquet/internal/encoding/...` and `./parquet/file/...`, and `go vet` is 
clean for the changed packages. The full test suite was not run locally.
   
   ### Are there any user-facing changes?
   
   These batches can now be written, and their values have an empty dictionary 
when read back. No API changes.
   
   This PR was prepared with AI assistance (Claude Code).
   
   🤖 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