-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbowrecord.go
More file actions
47 lines (41 loc) · 1.1 KB
/
bowrecord.go
File metadata and controls
47 lines (41 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package bow
import (
"errors"
"fmt"
"github.com/apache/arrow/go/v8/arrow"
"github.com/apache/arrow/go/v8/arrow/array"
)
func newRecord(metadata Metadata, series ...Series) (arrow.Record, error) {
var fields []arrow.Field
var arrays []arrow.Array
var nRows int64
if len(series) != 0 && series[0].Array != nil {
nRows = int64(series[0].Array.Len())
}
for _, s := range series {
if s.Array == nil {
return nil, errors.New("empty Series")
}
if s.Name == "" {
return nil, errors.New("empty Series name")
}
if getBowTypeFromArrowFingerprint(s.Array.DataType().Fingerprint()) == Unknown {
return nil, fmt.Errorf("unsupported type '%s'", s.Array.DataType())
}
if int64(s.Array.Len()) != nRows {
return nil,
fmt.Errorf(
"bow.Series '%s' has a length of %d, which is different from the previous ones",
s.Name, s.Array.Len())
}
fields = append(fields, arrow.Field{
Name: s.Name,
Type: s.Array.DataType(),
Nullable: true,
})
arrays = append(arrays, s.Array)
}
return array.NewRecord(
arrow.NewSchema(fields, &metadata.Metadata),
arrays, nRows), nil
}