Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go/adbc/sqldriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ func (r *rows) Next(dest []driver.Value) error {
dest[i] = nil
continue
}

if colUnion, ok := col.(array.Union); ok {
col = colUnion.Field(colUnion.ChildID(int(r.curRow)))
}
switch col := col.(type) {
case *array.Boolean:
dest[i] = col.Value(int(r.curRow))
Expand Down
54 changes: 52 additions & 2 deletions go/adbc/sqldriver/driver_internals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,16 @@ func TestColumnTypeDatabaseTypeName(t *testing.T) {
}

var (
tz = time.FixedZone("North Idaho", -int((8 * time.Hour).Seconds()))
testTime = time.Date(2023, time.January, 26, 15, 40, 39, 123456789, tz)
tz = time.FixedZone("North Idaho", -int((8 * time.Hour).Seconds()))
testTime = time.Date(2023, time.January, 26, 15, 40, 39, 123456789, tz)
stringField = arrow.Field{
Name: "str",
Type: arrow.BinaryTypes.String,
}
int32Field = arrow.Field{
Name: "int",
Type: arrow.PrimitiveTypes.Int32,
}
)

func TestNextRowTypes(t *testing.T) {
Expand Down Expand Up @@ -254,6 +262,48 @@ func TestNextRowTypes(t *testing.T) {
},
golangValue: decimal256.FromU64(10),
},
{
arrowType: arrow.SparseUnionOf([]arrow.Field{stringField, int32Field}, []arrow.UnionTypeCode{0, 1}),
arrowValueFunc: func(t *testing.T, b array.Builder) {
t.Helper()
ub := b.(array.UnionBuilder)
ub.Append(0)
ub.Child(0).(*array.StringBuilder).Append("my-string")
ub.Child(1).AppendEmptyValue()
},
golangValue: "my-string",
},
{
arrowType: arrow.SparseUnionOf([]arrow.Field{stringField, int32Field}, []arrow.UnionTypeCode{0, 1}),
arrowValueFunc: func(t *testing.T, b array.Builder) {
t.Helper()
ub := b.(array.UnionBuilder)
ub.Append(1)
ub.Child(1).(*array.Int32Builder).Append(100)
ub.Child(0).AppendEmptyValue()

},
golangValue: int32(100),
},
{
arrowType: arrow.DenseUnionOf([]arrow.Field{int32Field, stringField}, []arrow.UnionTypeCode{10, 20}),
arrowValueFunc: func(t *testing.T, b array.Builder) {
t.Helper()
ub := b.(array.UnionBuilder)
ub.Append(20)
ub.Child(1).(*array.StringBuilder).Append("my-string")
},
golangValue: "my-string",
},
{
arrowType: arrow.DenseUnionOf([]arrow.Field{int32Field, stringField}, []arrow.UnionTypeCode{10, 20}),
arrowValueFunc: func(t *testing.T, b array.Builder) {
t.Helper()
b.(array.UnionBuilder).Append(10)
b.(array.UnionBuilder).Child(0).(*array.Int32Builder).Append(100)
},
golangValue: int32(100),
},
}

for i, test := range tests {
Expand Down