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.
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.
- 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]
- When enable case 2, all the column data is
empty value. The output is
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
Describe the bug, including details regarding any error messages, version, and platform.
With a
BinaryBuilder, I need to append some empty values (""), but notNull. The problem is when all the column data are empty (""), the data in the generated arrow table isNull.Using the below sample code, issue could be reproduced easily.
There are 2 cases in the code.
emptyvalue and a real value. The output isemptyvalue. The output isYou can see the case 2 has all values
nilinstead of[]. Here the expected output of case 2 isYour reply is highly appreciated, thanks!
Component(s)
Other