zeroshade commented on code in PR #13381:
URL: https://github.com/apache/arrow/pull/13381#discussion_r897275987
##########
go/arrow/array/string_test.go:
##########
@@ -206,3 +206,37 @@ func TestStringReset(t *testing.T) {
assert.Equal(t, "string1", string2.Value(0))
}
+
+func TestStringInvalidOffsets(t *testing.T) {
+ const expectedPanic = "arrow/array: string offsets out of bounds of
data buffer"
+
+ makeBuffers := func(offsets []int32, data string) []*memory.Buffer {
+ offsetBuf :=
memory.NewBufferBytes(arrow.Int32Traits.CastToBytes(offsets))
+ return []*memory.Buffer{nil, offsetBuf,
memory.NewBufferBytes([]byte(data))}
+ }
+
+ assert.NotPanics(t, func() {
+ buffers := makeBuffers([]int32{}, "")
+ array.NewStringData(array.NewData(arrow.BinaryTypes.String, 0,
buffers, nil, 0, 0))
+ }, "empty array has no offsets")
+
+ assert.NotPanics(t, func() {
+ buffers := makeBuffers([]int32{0, 5}, "")
Review Comment:
this is an invalid string array and should be erroring. The offsets indicate
that the value for index 0 should be 5 bytes long, but your data array is
empty. This is invalid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]