Skip to content

Commit

Permalink
fix null deserialization issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-rpanchapakesan committed Dec 6, 2023
1 parent f9fca70 commit 94135f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,20 @@ func arrowToValue(
case arrow.INT32:
values := vectorData.ListValues().(*array.Int32).Int32Values()
for i := 0; i < vectorData.Len(); i++ {
destcol[i] = values[i*dim : (i+1)*dim]
if vectorData.IsNull(i) {
destcol[i] = []int32(nil)
} else {
destcol[i] = values[i*dim : (i+1)*dim]
}
}
case arrow.FLOAT32:
values := vectorData.ListValues().(*array.Float32).Float32Values()
for i := 0; i < vectorData.Len(); i++ {
destcol[i] = values[i*dim : (i+1)*dim]
if vectorData.IsNull(i) {
destcol[i] = []float32(nil)
} else {
destcol[i] = values[i*dim : (i+1)*dim]
}
}
default:
return fmt.Errorf("unsupported element type %q for a vector", datatype.Elem().String())
Expand Down
6 changes: 4 additions & 2 deletions converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,15 @@ func TestArrowToValue(t *testing.T) {
},
{
logical: "vector",
values: [][]int32{{1, 2, 3}, {4, 5, 6}},
values: [][]int32{nil, {1, 2, 3}},
builder: array.NewFixedSizeListBuilder(pool, 3, &arrow.Int32Type{}),
append: func(b array.Builder, vs interface{}) {
for _, v := range vs.([][]int32) {
lb := b.(*array.FixedSizeListBuilder)
vb := lb.ValueBuilder().(*array.Int32Builder)
if len(v) == 0 {
lb.AppendNull()
vb.AppendValues([]int32{-1, -1, -1}, nil)
continue
}

Expand All @@ -885,14 +886,15 @@ func TestArrowToValue(t *testing.T) {
},
{
logical: "vector",
values: [][]float32{{1.1, 2.2, 3}, {4.4, 5.5, 6}},
values: [][]float32{nil, {1.1, 2.2, 3}},
builder: array.NewFixedSizeListBuilder(pool, 3, &arrow.Float32Type{}),
append: func(b array.Builder, vs interface{}) {
for _, v := range vs.([][]float32) {
lb := b.(*array.FixedSizeListBuilder)
vb := lb.ValueBuilder().(*array.Float32Builder)
if len(v) == 0 {
lb.AppendNull()
vb.AppendValues([]float32{-1, -1, -1}, nil)
continue
}

Expand Down

0 comments on commit 94135f8

Please sign in to comment.