hcrosse opened a new issue, #1482:
URL: https://github.com/apache/arrow-go/issues/1482
### Describe the bug, including details regarding any error messages,
version, and platform.
`scalar.MakeArrayFromScalar(sc, 0, mem)` panics when `sc` is a dictionary
scalar whose value type is `large_utf8`, `large_binary`, `string_view`, `bool`,
a nested type, run-end encoded or an extension type. Valid and null scalars
both panic. Dictionary scalars of `utf8` or `float64` values already return an
empty array.
I reproduced this on main at `66722e30` and on v18.8.0, on macOS arm64 with
Go 1.26.10.
**Reproduction**
Save this as `main.go` in a new subdirectory of an arrow-go checkout at
`66722e30df98ddd6f7bb46023fa13287b84308f6`, then run `go run .` from that
directory:
```go
package main
import (
"fmt"
"github.com/apache/arrow-go/v18/arrow"
"github.com/apache/arrow-go/v18/arrow/memory"
"github.com/apache/arrow-go/v18/arrow/scalar"
)
func main() {
dt := &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int8,
ValueType: arrow.BinaryTypes.LargeString}
arr, err := scalar.MakeArrayFromScalar(scalar.NewNullDictScalar(dt), 0,
memory.DefaultAllocator)
fmt.Println(arr, err)
}
```
It panics with:
```text
panic: arrow/array: unsupported builder for value type of
*arrow.DictionaryType
```
**Expected behavior**
An empty `dictionary<values=large_utf8, indices=int8>` array and no error.
**Cause**
For length zero, `MakeArrayFromScalar` builds the result with
`array.NewBuilder`. For a dictionary type that creates a dictionary builder,
and its memo table supports fewer value types than dictionary arrays do:
https://github.com/apache/arrow-go/blob/66722e30df98ddd6f7bb46023fa13287b84308f6/arrow/scalar/scalar.go#L784-L803
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]