-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolumn.go
102 lines (77 loc) · 1.31 KB
/
column.go
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package spannermodel
const (
MinWidth = 1
MaxWidth = 2621440
)
type ColumnWidther interface {
Width() int64
}
type ColumnType interface {
Name() string
}
type BoolType struct{}
func (BoolType) Name() string {
return `BOOL`
}
type BytesType struct {
width int64
}
func (t *BytesType) Width() int64 {
return t.width
}
func (t BytesType) Name() string {
return `BYTES`
}
type DateType struct{}
func (DateType) Name() string {
return `DATE`
}
type Float64Type struct{}
func (Float64Type) Name() string {
return `FLOAT64`
}
type Int64Type struct{}
func (Int64Type) Name() string {
return `INT64`
}
type JSONType struct{}
func (JSONType) Name() string {
return `JSON`
}
type NumericType struct{}
func (NumericType) Name() string {
return `NUMERIC`
}
type StringType struct {
width int64
}
func (t *StringType) Width() int64 {
return t.width
}
func (t StringType) Name() string {
return `STRING`
}
type TimestampType struct{}
func (TimestampType) Name() string {
return `TIMESTAMP`
}
func BoolColumn(name string) Column {
return &column{
name: name,
typ: BoolType{},
}
}
func Int64Column(name string) Column {
return &column{
name: name,
typ: Int64Type{},
}
}
func StringColumn(name string, width int64) Column {
return &column{
name: name,
typ: &StringType{
width: width,
},
}
}