1
1
package v4
2
2
3
- type ColumnType uint32
3
+ type ColumnTypeCode uint32
4
4
5
5
const (
6
- ColumnTypeUnknown ColumnType = iota
6
+ ColumnTypeUnknown ColumnTypeCode = iota
7
7
ColumnTypeTag
8
8
ColumnTypeTime
9
9
ColumnTypeFieldUnknown
@@ -15,36 +15,37 @@ const (
15
15
ColumnTypeFieldGeometry
16
16
)
17
17
18
- type TimeUnit uint32
18
+ type TimeUnitCode uint32
19
19
20
20
const (
21
- TimeUnitUnknown TimeUnit = iota
21
+ TimeUnitUnknown TimeUnitCode = iota
22
22
TimeUnitSecond
23
23
TimeUnitMillisecond
24
24
TimeUnitMicrosecond
25
25
TimeUnitNanosecond
26
26
)
27
27
28
28
type TskvTableSchema struct {
29
- Tenant string `json:"tenant"`
30
- Db string `json:"db"`
31
- Name string `json:"name"`
32
- SchemaVersion uint64 `json:"schema_version"`
33
- NextColumnID uint32 `json:"next_column_id"`
34
- Columns []TableColumn `json:"columns"`
35
- ColumnsIndex map [string ]uint32 `json:"columns_index"`
29
+ // Tenant string `json:"tenant"`
30
+ // Db string `json:"db"`
31
+ Name string `json:"name"`
32
+ // SchemaId uint64 `json:"schema_id"` // v2.4.0 field
33
+ // SchemaVersion uint64 `json:"schema_version"` // v2.4.1 field
34
+ // NextColumnID uint32 `json:"next_column_id"`
35
+ Columns []TableColumn `json:"columns"`
36
+ // ColumnsIndex map[string]uint32 `json:"columns_index"`
36
37
}
37
38
38
39
type TableColumn struct {
39
40
ID uint64 `json:"id"`
40
41
Name string `json:"name"`
41
42
ColumnType interface {} `json:"column_type"`
42
- Encoding interface {} `json:"encoding"`
43
+ // Encoding interface{} `json:"encoding"`
43
44
}
44
45
45
46
type ColumnTypeUnited struct {
46
- ColumnType ColumnType
47
- TimeUnit TimeUnit
47
+ ColumnType ColumnTypeCode
48
+ TimeUnit TimeUnitCode
48
49
}
49
50
50
51
func (c * TableColumn ) GetColumnTypeUnited () ColumnTypeUnited {
@@ -56,6 +57,54 @@ func (c *TableColumn) GetColumnTypeUnited() ColumnTypeUnited {
56
57
ColumnType : ColumnTypeTag ,
57
58
TimeUnit : TimeUnitUnknown ,
58
59
}
60
+ } else {
61
+ // In cnosdb-v2.4.0, columnType is string
62
+ // After cnosdb-v2.4.0, columnType is string or object
63
+ columnTypeCode := ColumnTypeUnknown
64
+ timeUnitCode := TimeUnitUnknown
65
+ switch columnType {
66
+ case "TAG_STRING" :
67
+ // "column_type": "TAG_STRING"
68
+ return ColumnTypeUnited {
69
+ ColumnType : ColumnTypeTag ,
70
+ TimeUnit : TimeUnitUnknown ,
71
+ }
72
+ case "FIELD_STRING" :
73
+ // "column_type": "FIELD_STRING"
74
+ columnTypeCode = ColumnTypeFieldString
75
+ case "FIELD_BIGINT" :
76
+ // "column_type": "FIELD_BIGINT""
77
+ columnTypeCode = ColumnTypeFieldInteger
78
+ case "FIELD_BIGINT UNSIGNED" :
79
+ // "column_type": "FIELD_BIGINT UNSIGNED""
80
+ columnTypeCode = ColumnTypeFieldUnsigned
81
+ case "FIELD_DOUBLE" :
82
+ // "column_type": "FIELD_STRING"
83
+ columnTypeCode = ColumnTypeFieldFloat
84
+ case "FIELD_BOOLEAN" :
85
+ // "column_type": "FIELD_BOOLEAN""
86
+ columnTypeCode = ColumnTypeFieldBoolean
87
+ case "TIME_TIMESTAMP(SECOND)" :
88
+ // "column_type": "TIME_TIMESTAMP(SECOND)""
89
+ columnTypeCode = ColumnTypeTime
90
+ timeUnitCode = TimeUnitSecond
91
+ case "TIME_TIMESTAMP(MILLISECOND)" :
92
+ // "column_type": "TIME_TIMESTAMP(MILLISECOND)""
93
+ columnTypeCode = ColumnTypeTime
94
+ timeUnitCode = TimeUnitMillisecond
95
+ case "TIME_TIMESTAMP(MICROSECOND)" :
96
+ // "column_type": "TIME_TIMESTAMP(MICROSECOND)""
97
+ columnTypeCode = ColumnTypeTime
98
+ timeUnitCode = TimeUnitMicrosecond
99
+ case "TIME_TIMESTAMP(NANOSECOND)" :
100
+ // "column_type": "TIME_TIMESTAMP(NANOSECOND)""
101
+ columnTypeCode = ColumnTypeTime
102
+ timeUnitCode = TimeUnitNanosecond
103
+ }
104
+ return ColumnTypeUnited {
105
+ ColumnType : columnTypeCode ,
106
+ TimeUnit : timeUnitCode ,
107
+ }
59
108
}
60
109
case map [string ]interface {}:
61
110
if timeUnitObj := columnType ["Time" ]; timeUnitObj != nil {
0 commit comments