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
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 @@ -25,6 +25,7 @@ import (
"github.com/apache/arrow-go/v18/arrow/array"
"github.com/apache/arrow-go/v18/arrow/bitutil"
"github.com/apache/arrow-go/v18/arrow/memory"
"github.com/apache/arrow-go/v18/internal/json"
"github.com/stretchr/testify/assert"
)

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
Loading