Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion arrow/array/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ func (b *StringViewBuilder) UnmarshalOne(dec *json.Decoder) error {
default:
return &json.UnmarshalTypeError{
Value: fmt.Sprint(t),
Type: reflect.TypeOf([]byte{}),
Type: reflect.TypeOf(string("")),
Offset: dec.InputOffset(),
}
}
Expand Down
19 changes: 19 additions & 0 deletions arrow/array/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package array_test

import (
"bytes"
"encoding/json"
"reflect"
"testing"

Expand Down Expand Up @@ -902,6 +903,24 @@ func TestStringViewBuilder_Empty(t *testing.T) {
a.Release()
}

func TestStringViewBuilderUnmarshalOneWrongType(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
defer mem.AssertSize(t, 0)

bldr := array.NewStringViewBuilder(mem)
defer bldr.Release()

dec := json.NewDecoder(bytes.NewReader([]byte(`1`)))
err := bldr.UnmarshalOne(dec)

assert.Error(t, err)
var ute *json.UnmarshalTypeError
assert.ErrorAs(t, err, &ute)
if assert.NotNil(t, ute) {
assert.Equal(t, reflect.TypeOf(""), ute.Type)
}
}

// TestStringReset tests the Reset() method on the String type by creating two different Strings and then
// resetting the contents of string2 with the values from string1.
func TestStringViewReset(t *testing.T) {
Expand Down