hcrosse opened a new issue, #1535:
URL: https://github.com/apache/arrow-go/issues/1535

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   `NewExtensionArrayWithStorage` panics for nonempty dictionary arrays: 
`arrow/array: no dictionary set in Data for Dictionary array`. For empty 
arrays, it drops the dictionary, but `ValidateFull` returns `nil` on main.
   
   I reproduced both on v18.8.0 and main, with Go 1.26.10 on macOS arm64.
   
   ```go
   dictType := &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int8, 
ValueType: arrow.BinaryTypes.String}
   storage, _ := array.DictArrayFromJSON(memory.DefaultAllocator, dictType, 
`[0, null, 1, 0]`, `["a", "b"]`)
   ext := array.NewExtensionArrayWithStorage(extensions.NewOpaqueType(dictType, 
"t", "v"), storage)
   fmt.Println(ext)
   fmt.Println("ValidateFull:", array.ValidateFull(ext))
   ```
   
   Actual output:
   
   ```text
   panic: arrow/array: no dictionary set in Data for Dictionary array
   ```
   
   Expected: wrapping succeeds and preserves the dictionary `["a", "b"]` and 
indices `[0, null, 1, 0]`. `ValidateFull` returns `nil`. An empty array also 
keeps its dictionary.
   
   **Cause**
   
   `NewExtensionArrayWithStorage` copies the storage buffers, children, null 
count and offset into new extension data, but omits the dictionary.
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/arrow/array/extension.go#L72-L83
   
   The C++ `ExtensionArray` constructor copies the storage data, including its 
dictionary, and changes the type.
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/arrow/extension_type.cc#L82-L91
   
   I have a patch with tests and can open a PR.
   
   ### Component(s)
   
   Other
   


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