ysuliu opened a new issue, #625:
URL: https://github.com/apache/arrow-go/issues/625
### Describe the bug, including details regarding any error messages,
version, and platform.
With a `BinaryBuilder`, I need to append some empty values (`""`), but not
`Null`. The problem is when **all** the column data are empty (`""`), the data
in the generated arrow table is `Null`.
Using the below sample code, issue could be reproduced easily.
```go
func testTable() {
pool := memory.NewGoAllocator()
fields := []arrow.Field{
{
Name: "id",
Type: arrow.BinaryTypes.Binary,
},
}
schema := arrow.NewSchema(fields, nil)
builder := array.NewRecordBuilder(pool, schema)
defer builder.Release()
idBuilder := builder.Field(0).(*array.BinaryBuilder)
defer idBuilder.Release()
// Case #1: Empty + Data
//idBuilder.Append([]byte(""))
//idBuilder.Append([]byte(""))
//idBuilder.Append([]byte("SGVsbG8sIFdvcmxkIQ=="))
// Case #2: All Empty
idBuilder.Append([]byte(""))
idBuilder.Append([]byte(""))
idBuilder.Append([]byte(""))
records := builder.NewRecordBatch()
defer records.Release()
table := array.NewTableFromRecords(schema, []arrow.RecordBatch{records})
tr := array.NewTableReader(table, 0)
defer tr.Release()
for n := 0; tr.Next(); n++ {
record := tr.RecordBatch()
defer record.Release()
for rowIdx := range int(record.NumRows()) {
for _, col := range record.Columns() {
data, _ := col.(*array.Binary)
v := data.Value(rowIdx)
if v == nil {
fmt.Printf("NULL\n")
} else {
fmt.Printf("%v\n", v)
}
}
}
}
}
```
There are 2 cases in the code.
1. When enable case 1, the column data includes the `empty` value and a real
value. The output is
```
[]
[]
[83 71 86 115 98 71 56 115 73 70 100 118 99 109 120 107 73 81 61 61]
```
2. When enable case 2, all the column data is `empty` value. The output is
```
NULL
NULL
NULL
```
You can see the case 2 has all values `nil` instead of `[]`. Here the
expected output of case 2 is
```
[]
[]
[]
```
Your reply is highly appreciated, thanks!
### 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]