You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by sb...@apache.org on 2019/05/17 15:47:28 UTC
[arrow] branch master updated: ARROW-5314: [Go] fix bug for String
Arrays with offset
This is an automated email from the ASF dual-hosted git repository.
sbinet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 1ed608a ARROW-5314: [Go] fix bug for String Arrays with offset
1ed608a is described below
commit 1ed608aa94f0d22cfa69c81687006b4ebaefa258
Author: Jim Walker <po...@users.noreply.github.com>
AuthorDate: Fri May 17 17:47:12 2019 +0200
ARROW-5314: [Go] fix bug for String Arrays with offset
Author: Jim Walker <po...@users.noreply.github.com>
Author: Jim <ji...@capsule8.com>
Closes #4307 from poopoothegorilla/poopoothegorilla-patch-1 and squashes the following commits:
cf4a2dd4 <Jim> arrow/array: run fmt on string tests
8611ec0a <Jim> arrow/string: move offset logic to value method
6233448c <Jim Walker> ARROW-5314: include offset when printing string value
a1c77365 <Jim Walker> ARROW-5314: add test case to identify bug
---
go/arrow/array/string.go | 5 ++++-
go/arrow/array/string_test.go | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/go/arrow/array/string.go b/go/arrow/array/string.go
index dbc340d..8356d02 100644
--- a/go/arrow/array/string.go
+++ b/go/arrow/array/string.go
@@ -46,7 +46,10 @@ func NewStringData(data *Data) *String {
}
// Value returns the slice at index i. This value should not be mutated.
-func (a *String) Value(i int) string { return a.values[a.offsets[i]:a.offsets[i+1]] }
+func (a *String) Value(i int) string {
+ i = i + a.array.data.offset
+ return a.values[a.offsets[i]:a.offsets[i+1]]
+}
func (a *String) ValueOffset(i int) int { return int(a.offsets[i]) }
func (a *String) String() string {
diff --git a/go/arrow/array/string_test.go b/go/arrow/array/string_test.go
index 828b32a..a4bdcdd 100644
--- a/go/arrow/array/string_test.go
+++ b/go/arrow/array/string_test.go
@@ -103,6 +103,20 @@ func TestStringArray(t *testing.T) {
if got, want := arr.String(), `["hello" "世界" (null) "bye"]`; got != want {
t.Fatalf("got=%q, want=%q", got, want)
}
+ slice := array.NewSliceData(arr.Data(), 2, 4)
+ defer slice.Release()
+
+ sub1 := array.MakeFromData(slice)
+ defer sub1.Release()
+
+ v, ok := sub1.(*array.String)
+ if !ok {
+ t.Fatalf("could not type-assert to array.String")
+ }
+
+ if got, want := v.String(), `[(null) "bye"]`; got != want {
+ t.Fatalf("got=%q, want=%q", got, want)
+ }
}
func TestStringBuilder_Empty(t *testing.T) {