[Go] Allow adding existing arrays into structs
- Dominant language
- Assembly
- Stars
- 404
- Forks
- 145
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 87
Description
### Describe the enhancement requested
Hi! We have a use case, in which we have existing Arrow arrays and we want to compose them to struct. Unfortunately, currently `StructBuilder` does not support it. So currently we have to copy all values from the specific Arrow array to the similar array in struct one by one. It would be great if we can just reuse existing array without manual copying.
What we do now?
Something like this:
```
for j := 0; j < int(numRows); j++ {
sb.Append(true)
for i := 0; i < structCol.NumField(); i++ {
newInternalCol := internalCols[i]
if newInternalCol.DataType().ID() == arrow.STRING {
sb.FieldBuilder(i).(*array.StringBuilder).Append(newInternalCol.(*array.String).Value(j))
} else if newInternalCol.DataType().ID() == arrow.INT8 {
sb.FieldBuilder(i).(*array.Int8Builder).Append(newInternalCol.(*array.Int8).Value(j))
```
What we want:
```
sb.SetColumn(i, newInternalCol[i])
```
The main problem here is not this few lines of code that we need to write, but manual memory copying. Is it doable?
### Component(s)
Go
Contributor guide
Assessment
This issue has not been assessed yet.