@@ -10,7 +10,10 @@ import (
10
10
"testing"
11
11
"time"
12
12
13
+ "github.com/apache/arrow-go/v18/arrow"
14
+ "github.com/apache/arrow-go/v18/arrow/array"
13
15
"github.com/apache/arrow-go/v18/arrow/ipc"
16
+ "github.com/apache/arrow-go/v18/arrow/memory"
14
17
"github.com/google/go-cmp/cmp"
15
18
"github.com/stretchr/testify/require"
16
19
@@ -440,3 +443,39 @@ func TestFromRecord(t *testing.T) {
440
443
t .Errorf ("Result mismatch (-want +got):\n %s" , diff )
441
444
}
442
445
}
446
+
447
+ func TestFromRecordStringView (t * testing.T ) {
448
+ pool := memory .NewGoAllocator ()
449
+ require .NotNil (t , pool )
450
+ schema := arrow .NewSchema ([]arrow.Field {
451
+ arrow.Field {Name : "sv" , Type : & arrow.StringViewType {}, Nullable : false },
452
+ arrow.Field {Name : "svn" , Type : & arrow.StringViewType {}, Nullable : true },
453
+ }, nil )
454
+ require .NotNil (t , schema )
455
+ b := array .NewRecordBuilder (pool , schema )
456
+ defer b .Release ()
457
+
458
+ testStrings := []string {"foo" , "" , "" , "🦥" , "bar" }
459
+ notNull := []bool {true , true , false , true , true }
460
+ b .Field (0 ).(* array.StringViewBuilder ).AppendValues (testStrings , nil )
461
+ b .Field (1 ).(* array.StringViewBuilder ).AppendValues (testStrings , notNull )
462
+ record := b .NewRecord ()
463
+ defer record .Release ()
464
+
465
+ got , err := data .FromArrowRecord (record )
466
+ require .NoError (t , err )
467
+
468
+ want := data .NewFrame ("" ,
469
+ data .NewField ("sv" , data.Labels {}, testStrings ),
470
+ data .NewField ("svn" , data.Labels {}, []* string {
471
+ stringPtr ("foo" ),
472
+ stringPtr ("" ),
473
+ nil ,
474
+ stringPtr ("🦥" ),
475
+ stringPtr ("bar" ),
476
+ }),
477
+ )
478
+ if diff := cmp .Diff (want , got , data .FrameTestCompareOptions ()... ); diff != "" {
479
+ t .Errorf ("Result mismatch (-want +got):\n %s" , diff )
480
+ }
481
+ }
0 commit comments