-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathtypes.go
More file actions
58 lines (54 loc) · 1.55 KB
/
types.go
File metadata and controls
58 lines (54 loc) · 1.55 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
48
49
50
51
52
53
54
55
56
57
58
package client
import (
"github.com/apache/arrow-go/v18/arrow"
)
func (*Client) arrowTypeToSqliteStr(t arrow.DataType) string {
switch t.ID() {
case arrow.BINARY, arrow.LARGE_BINARY:
return "blob"
case arrow.INT8, arrow.INT16, arrow.INT32, arrow.INT64, arrow.UINT8, arrow.UINT16, arrow.UINT32, arrow.UINT64:
return "integer"
case arrow.FLOAT16, arrow.FLOAT32, arrow.FLOAT64:
return "real"
case arrow.BOOL:
return "boolean"
case arrow.TIMESTAMP:
return "timestamp"
// case arrow.STRING, arrow.LARGE_STRING:
default:
return "text"
}
}
func (*Client) arrowTypeToSqlite(t arrow.DataType) arrow.DataType {
switch t.ID() {
case arrow.INT8, arrow.INT16, arrow.INT32, arrow.INT64, arrow.UINT8, arrow.UINT16, arrow.UINT32, arrow.UINT64:
return arrow.PrimitiveTypes.Int64
case arrow.FLOAT16, arrow.FLOAT32, arrow.FLOAT64:
return arrow.PrimitiveTypes.Float64
case arrow.BOOL:
return arrow.FixedWidthTypes.Boolean
case arrow.TIMESTAMP:
return arrow.FixedWidthTypes.Timestamp_us
// case arrow.BINARY, arrow.LARGE_BINARY, arrow.STRING, arrow.LARGE_STRING:
default:
return arrow.BinaryTypes.LargeString
}
}
func (*Client) sqliteTypeToArrowType(t string) arrow.DataType {
switch t {
case "integer":
return arrow.PrimitiveTypes.Int64
case "real":
return arrow.PrimitiveTypes.Float64
case "text":
return arrow.BinaryTypes.LargeString
case "blob":
return arrow.BinaryTypes.LargeBinary
case "boolean":
return arrow.FixedWidthTypes.Boolean
case "timestamp":
return arrow.FixedWidthTypes.Timestamp_us
default:
panic("unknown type: " + t)
}
}